prodevans / LEAP2.0

Leap 2.0 is a platform offered by Complete open Source Solutions(COSS),where students from different campus irrespective of all platforms can join to explore themselves with the limitless IT world by gaining knowledge on open source cutting edge technologies on demand and get opportunity to work on live projects.
3 stars 6 forks source link

Python Test (Fibonacci) #10

Closed jeethub26230 closed 4 years ago

jeethub26230 commented 4 years ago

Create a program which returns a Fibonacci Series till the given number.



Eg :- 
    fib(x) : Gives the Fibonacci till x number.
```.
Debasis500 commented 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
joellui commented 4 years ago

Click the link ---> My code

vamsipvk2203 commented 4 years ago

Fibonacci until given number

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)
srvk99 commented 4 years ago

Fibonacci Numbers

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=" ") 
simranmaharana commented 4 years ago

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

bvjhansisaketa commented 4 years ago
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
kautilya2000 commented 4 years ago
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
VijitSai commented 4 years ago
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
aryaman-01 commented 4 years ago

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
Anant777 commented 4 years ago

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

sahoo97 commented 4 years ago

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

sravan950 commented 4 years ago

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)

DinuDante commented 4 years ago
#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...")
megha-biswas01 commented 4 years ago
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")