Author Topic: Python - Tuple Assignment to display Fibonacci Series  (Read 1645 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Python - Tuple Assignment to display Fibonacci Series
« on: January 04, 2012, 04:28:34 pm »
Here is the Python program explaining Tuple Assignment to display Fibonacci Series.

Code: (Python)
#Python Source File


first, next, i = (1, 1, 1)
while i <= 25:
    print 'Fibonacci Series Term %d is %d' %(i, first)
    first, next, i = (next, first + next, i + 1)


Fibonacci Series Term 1 is 1
Fibonacci Series Term 2 is 1
Fibonacci Series Term 3 is 2
Fibonacci Series Term 4 is 3
Fibonacci Series Term 5 is 5
Fibonacci Series Term 6 is 8
Fibonacci Series Term 7 is 13
Fibonacci Series Term 8 is 21
Fibonacci Series Term 9 is 34
Fibonacci Series Term 10 is 55
Fibonacci Series Term 11 is 89
Fibonacci Series Term 12 is 144
Fibonacci Series Term 13 is 233
Fibonacci Series Term 14 is 377
Fibonacci Series Term 15 is 610
Fibonacci Series Term 16 is 987
Fibonacci Series Term 17 is 1597
Fibonacci Series Term 18 is 2584
Fibonacci Series Term 19 is 4181
Fibonacci Series Term 20 is 6765
Fibonacci Series Term 21 is 10946
Fibonacci Series Term 22 is 17711
Fibonacci Series Term 23 is 28657
Fibonacci Series Term 24 is 46368
Fibonacci Series Term 25 is 75025

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1