Created
December 19, 2015 18:14
-
-
Save eff-kay/6be202d74275b47dcd73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def prime_test(n): | |
if n==2: | |
return True | |
if n==1: | |
return False | |
if n%2==0 and n!=2: | |
return False | |
test=True | |
for i in xrange(2,n): | |
if n%i ==0: | |
test= False | |
break | |
return test | |
def fib_func(n): | |
if( n == 0): | |
sys.stdout.write("0\n") | |
else: | |
x1= 0 | |
sys.stdout.write(str(0)+"\n") | |
x2= 1 | |
sys.stdout.write(str(1)+"\n") | |
for i in range(1,n): | |
y = (x1 + x2) | |
x1 = x2 | |
x2 = y | |
checks_prints(y) | |
def checks_prints(n): | |
if n%3 ==0 and n!=0 and n!=3: | |
sys.stdout.write("Buzz\n") | |
elif n%5 == 0 and n!=0 and n!=5: | |
sys.stdout.write("Fizz\n") | |
elif n%3==0 and n%5==0 and n!=0: | |
sys.stdout.write("Buzz, Fizz") | |
elif prime_test(n) and n!=3 and n!=5 and n!=0: | |
sys.stdout.write("BuzzFizz\n") | |
elif n == 3: | |
sys.stdout.write("Buzz, BuzzFizz\n") | |
elif n==5: | |
sys.stdout.write("Fizz, BuzzFizz\n") | |
else: | |
sys.stdout.write(str(n)+"\n") | |
sys.stdout.write("enter the number n: \n") | |
n = int(sys.stdin.readline()) | |
if n <= 0: | |
print(" Enter a positive integer") | |
else: | |
fib_func(n) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment