Fibonacci series in Python
''' Read input from STDIN. Print your output to STDOUT '''
#Use input() to read input from STDIN and use print to write your output to STDOUT
import sys
def main():
# Write code here
val=input()
x=0
y=1
z=x+y
sys.stdout.write(str(x)+" "+str(y))
for i in range(val-2):
z=x+y
x=y
y=z
sys.stdout.write(" "+str(z))
main()
#Use input() to read input from STDIN and use print to write your output to STDOUT
import sys
def main():
# Write code here
val=input()
x=0
y=1
z=x+y
sys.stdout.write(str(x)+" "+str(y))
for i in range(val-2):
z=x+y
x=y
y=z
sys.stdout.write(" "+str(z))
main()
Comments
Post a Comment