Skip to content

it is a desired function from dynamic programming #12795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions dynamic_programming/lucas_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Giving the output
def lucas_func(n):
# PREDFINING THE VALUES
a = 2
b = 1

if n == 0:
return a

# GENERATING THE NUMBER
for i in range(2, n + 1):

Check failure on line 11 in dynamic_programming/lucas_function.py

GitHub Actions / ruff

Ruff (B007)

dynamic_programming/lucas_function.py:11:9: B007 Loop control variable `i` not used within loop body
c = a + b
a = b
b = c

return b


# USER INPUT
n = int(input("Enter the position n to find the nth Lucas Number: "))
print(f"The {n}th Lucas Number is: {lucas_func(n)}")

"""
THE OUTPUT:-
Enter the position n to find the nth Lucas Number: 6
The 6th Lucas Number is: 18
"""
21 changes: 21 additions & 0 deletions maths/area.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
"""

from math import pi, sqrt, tan
import numpy as np
from scipy.integrate import quad


def surface_area_cube(side_length: float) -> float:
@@ -264,6 +266,25 @@
return length * width


def area_of_parabola(x,a,b,c):
"""
Area under the parabola y = 1x² + 0x + 0 from x = 0 to x = 2 is 2.666666666666667
"""
return a * x**2 + b * x + c

Check failure on line 273 in maths/area.py

GitHub Actions / ruff

Ruff

maths/area.py:273:1: SyntaxError: unindent does not match any outer indentation level

def area_under_parabola(a, b, c, x1, x2):

Check failure on line 275 in maths/area.py

GitHub Actions / ruff

Ruff

maths/area.py:275:1: SyntaxError: Unexpected indentation
area, _ = quad(parabola, x1, x2, args=(a, b, c))
return area
#example usage
a = 1

Check failure on line 279 in maths/area.py

GitHub Actions / ruff

Ruff

maths/area.py:279:1: SyntaxError: unindent does not match any outer indentation level
b = 0

Check failure on line 280 in maths/area.py

GitHub Actions / ruff

Ruff

maths/area.py:280:1: SyntaxError: Unexpected indentation
c = 0
x1 = 0
x2 = 2

area = area_under_parabola(a, b, c, x1, x2)
print(f"Area under the parabola y = {a}x² + {b}x + {c} from x = {x1} to x = {x2} is {area}")

Check failure on line 286 in maths/area.py

GitHub Actions / ruff

Ruff (E501)

maths/area.py:286:89: E501 Line too long (92 > 88)

def area_square(side_length: float) -> float:
"""
Calculate the area of a square.