Advertisement
tsounakis

Untitled

Dec 15th, 2019
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. def fib(x):
  2.     a = 1
  3.     b = 1
  4.     j = 0
  5.     if x == 1:
  6.         return a
  7.     elif x == 2:
  8.         return b
  9.     else:
  10.         while x >= j + 1:
  11.             c = a+b
  12.             a=b
  13.             b=c
  14.             if is_prime(c):
  15.                 print(c)
  16.                 j += 1
  17.            
  18. def is_prime(num):
  19.     if num > 1:
  20.        for i in range(2,num):
  21.            if (num % i) == 0:
  22.                return False
  23.        else:
  24.            return True
  25.  
  26. fib(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement