| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -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 " | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments