Closed jeethub26230 closed 4 years ago
#fibonacci sequence up to nth term
a=int(input("How many terms:"))
n1,n2 = 0,1
count = 0
if a <= 0:
print("Enter positive number")
elif a == 1:
print("Fibonacci sequence")
print(n1)
else:
print("Fibonacci sequence:")
while count < a:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
def fibonacci(val):
a=0
b=1
print(a,b,end=' ')
for i in range(2,val):
c = a+b
if c < val:
print(c,end=' ')
else:
break
a = b
b = c
val = int(input('Enter the number: '))
fibonacci(val)
n = int(input("Enter the number: "))
def fib(n):
if n <= 1:
return(n)
else:
return(fib(n-1) + fib(n-2))
if (n<0):
print("Positive number please!")
else:
for i in range(n):
print(fib(i), end=" ")
n=int(input("enter the value of 'n':")) a = 0 b = 1 s = 0 c = 1 print("fibonacci series: ",end = " ") while(c <= n) print(s, end= " ") c+= 1 a=b b=s s=a+b
i=2
n=int(input("enter the number"))
a2=1
a1=0
print(a1,a2,end=' ')
while(i<n):
a3=a1+a2
print(a3,end=' ')
temp=a2
a1=temp
a2=a3
i=i+1
n = int(input("Enter the value of 'n': "))
a = 0
b = 1
sum = 0
count = 1
print("Fibonacci Series: ", end = " ")
while(count <= n):
print(sum, end = " ")
count += 1
a = b
b = sum
sum = a + b
n = int(input("No. of terms "))
a=0
b=1
flag = 0
while flag < n:
print(a)
c = a + b
a = b
b = c
flag += 1
nterms = int(input("Number of terms? "))
n1 = 0
n2 = 1
count = 0
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Your series is :")
while count < nterms:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
x=int(input("enter the limits)) i,j=0,1 print("fibonacci sequence : ") while i<x: print(i) nth=i+j i=j j=nth
n= int( input ("how many term : ")) m1=0 m2=1 c=0 if n<=0: print("enter posstive integer number") else print("Fibonacci sequence : ") while c<n print(m1) mth=m1+m2 m1=m2 m2=mth c=c+1
Number = int(input("\nPlease Enter the Range Number: "))
FirstValue = 0 SecondValue = 1
for Num in range(0, Number): if(Num <= 1): Next = Num else: Next = FirstValue + SecondValue FirstValue = SecondValue SecondValue = Next print(Next)
#This is Dinesh Behera
#Fibinacci Logic and Printing
def fibo(n):
a,b=0,1
print("Fibonacci Series:")
while a<n:
print(a)
c=a+b
a=b
b=c
#Driver Code
n=int(input("Enter upto limit:"))
if n>0:
fibo(n)
else:
print("\n Enter a positive number...")
def fibonacci():
n = int(input("How many terms? "))
n1, n2 = 0, 1
count = 0
if n <= 0:
print("Please enter a positive integer")
fibonacci()
elif n == 1:
print("Fibonacci sequence upto",n,":")
print(n1)
else:
print("Fibonacci sequence:")
while count < n:
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
print("Welcome")
fibonacci()
option=input(print("Do you want to continue:(y/n)"))
if (option == 'y'):
fibonacci()
else:
print("Thank You")
Create a program which returns a Fibonacci Series till the given number.