---
title: "菜鸟学Python - 斐波那契数列（Fibonacci）"
author: "ay_guobo"
date: "2011-10-26T08:36:59Z"
tags: []
categories: ["编程语言"]
slug: "python-fibonacci"
draft: false
lastmod: "2011-10-26T08:36:59Z"
id: 1214349
url: "https://GUOBO.iteye.com/blog/1214349"
---

Python语言: [Codee#23497](http://fayaa.com/code/view/23497/)

01 '''  
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 &lt; n:  
15         result.append(b)  
16         a, b = b, a+b  
17     return result  
18   
19 print fib(1000)