FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonprogram/Fibonacci number at master · zainabcodeplay/pythonprogram · GitHub
zainabcodeplay
pythonprogram
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonprogram
/
Fibonacci number
Copy path
More file actions
More file actions
Latest commit
History
History
History
17 lines (11 loc) · 309 Bytes
Breadcrumbs
pythonprogram
/
Fibonacci number
Copy path
File metadata and controls
17 lines (11 loc) · 309 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import math
def isPerfectSquare(x):
s = int(math.sqrt(x))
return s*s == x
def isFibonacci(n):
return isPerfectSquare(5*n*n + 4) or isPerfectSquare(5*n*n - 4)
for i in range(1,11):
if (isFibonacci(i) == True):
print i,"is a Fibonacci Number"
else:
print i,"is a not Fibonacci Number "
Back
|
FazBrowse Home
|
New Git URL