GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — some function of fibonacci sque · wusewolf/StarterLearningPython@dea750a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • fib
    • .fib02.py.swp
    • fib01.py
    • fib02.py
    • fib03.py
    • fib04.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎fib/.fib02.py.swp‎

Copy file name to clipboard
12 KB
Binary file not shown.
Collapse file

‎fib/fib01.py‎

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
4+
def fib(n):
5+
if n == 0:
6+
return 0
7+
elif n == 1:
8+
return 1
9+
else:
10+
return fib(n-1) + fib(n-2)
11+
12+
if __name__=="__main__":
13+
n = fib(4)
14+
print(n)
Collapse file

‎fib/fib02.py‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python
2+
# utf-8
3+
4+
from math import sqrt
5+
6+
def fib(n):
7+
return ((1+sqrt(5))**n - (1-sqrt(5))**n)/(2**n*sqrt(5))
8+
9+
if __name__=="__main__":
10+
f = fib(4)
11+
print(f)
Collapse file

‎fib/fib03.py‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python
2+
# utf-8
3+
4+
def fib(n):
5+
f = [0, 1]
6+
for i in range(n-2):
7+
f.append(f[-2] + f[-1])
8+
return f
9+
10+
if __name__ == "__main__":
11+
lst = fib(4)
12+
print(lst)
Collapse file

‎fib/fib04.py‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python
2+
#utf-8
3+
4+
def fib(n):
5+
a, b = 0, 1
6+
while n > 0:
7+
a, b = b, a + b
8+
n -= 1
9+
return a
10+
11+
if __name__ == "__main__":
12+
print(fib(4))

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.