Showing posts with label Fibonacci sequence in python. Show all posts
Showing posts with label Fibonacci sequence in python. Show all posts

Saturday, March 19, 2016

Fibonacci Sequence in Python

A program that will ask the user to give an integer number value and then it will generate the corresponding fibonacci number using Python as my programming language.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


def fibonacci_sequence(values):
  
   if values <= 1:
       return values
   else:
       return(fibonacci_sequence(values-1) + fibonacci_sequence(values-2))


print("-" * 30)
print(" FIBONACCI SEQUENCE PROGRAM ")
print("-" * 30)
items = int(input("Enter an Integer Number : "))


if items <= 0:
   print("Plese enter a positive integer")
else:
   print("The result is :")
   for a in range(items):
       print(fibonacci_sequence(a))