首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

初学者学Python - 斐波那契数列(Fibonacci)

2012-10-08 
菜鸟学Python - 斐波那契数列(Fibonacci)Python语言:?Codee#2349701?02?Created on 2011-10-2503?04?@a

菜鸟学Python - 斐波那契数列(Fibonacci)

Python语言:?Codee#2349701?'''
02?Created on 2011-10-25
03?
04?@author: Guo
05?'''
06?#-*- encoding:UTF-8 -*-?
07?
08?def?fib(n):?# return Fibonacci series up to n
09?????result?=?[]
10?????a,?b?=?0,?1
11????
12?????FibonacciUptoNumer?=?int(raw_input('Please input a Fibonacci Series up to Number : '))
13???? n?=??FibonacciUptoNumer
14?????while?b?<?n:
15?????????result.append(b)
16?????????a,?b?=?b,?a+b
17?????return?result
18?
19?print?fib(1000)

热点排行