-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathfibonacci.py
More file actions
70 lines (51 loc) · 1.56 KB
/
Copy pathfibonacci.py
File metadata and controls
70 lines (51 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
This is a Python script that takes a number as input from the
user and returns the corresponding number of Fibonacci terms.
It uses the formula for the nth term of the Fibonacci sequence
and functionally decomposes the calculations.
Fill in all the missing code in the functions and in main
"""
import math
import typing
import math
<<<<<<< HEAD
def get_input() -> int:
"""Gets input from the user and returns it as an integer"""
=======
def get_input(inputed) -> int:
>>>>>>> a3b976e3f0d4f1c701bb1e9334ad344c0d871413
return int(input())
def fibonacci_list(n: int) -> typing.List[int]:
"""Returns a list of the first n Fibonacci numbers"""
if isinstance(n, int):
fib_sequence = [1, 2]
for i in range(n-2):
add = fib_sequence[i] + fib_sequence[i + 1]
fib_sequence.append(add)
return fib_sequence
def fibonacci_single(n: int) -> int:
"""Returns the nth Fibonacci number"""
pass
def golden_section_num() -> float:
"""
Returns the golden section number (capital Phi)
"""
return (1 + math.sqrt(5)) / 2
def golden_section_reciprocal() -> float:
"""
Returns the reciprocal of the golden section number (lowercase phi)
"""
return (1 - math.sqrt(5)) / 2
def power(num: int, n: int) -> int:
"""Raises num to the nth power"""
result = math.pow(num, n)
return result
def sqrt(num: int) -> float:
"""Returns the square root of num"""
result = math.sqrt(num)
return result
def main():
"""Main function"""
pass
if __name__ == "__main__":
main()