We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents aca5270 + ea9b6a9 commit a18286bCopy full SHA for a18286b
1 file changed
Fibonacci number
@@ -0,0 +1,17 @@
1
+
2
+import math
3
+def isPerfectSquare(x):
4
+ s = int(math.sqrt(x))
5
+ return s*s == x
6
7
8
+def isFibonacci(n):
9
10
+ return isPerfectSquare(5*n*n + 4) or isPerfectSquare(5*n*n - 4)
11
12
13
+for i in range(1,11):
14
+ if (isFibonacci(i) == True):
15
+ print i,"is a Fibonacci Number"
16
+ else:
17
+ print i,"is a not Fibonacci Number "
0 commit comments