Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit eeb8824

Browse files
author
Amogh Singhal
authored
Create first_n_fibo.py
1 parent 8dd1b8c commit eeb8824

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎first_n_fibo.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Write a function that computes the
2+
# list of the first 100 Fibonacci numbers
3+
4+
FIB_ARR = [0, 1]
5+
6+
def first_n_fibo(n):
7+
if n < 2:
8+
return FIB_ARR
9+
else:
10+
while len(FIB_ARR) < n:
11+
FIB_ARR.append(FIB_ARR[-1] + FIB_ARR[-2])
12+
return FIB_ARR
13+
14+
15+
n = 10
16+
arr = first_n_fibo(n)
17+
print(arr)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /