python剑指offer系列斐波那契数列
2017-08-21 16:13
218 查看
大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项。
n<=39
网址:https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?tpId=13&tqId=11160&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking
代码:
n<=39
网址:https://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3?tpId=13&tqId=11160&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking
代码:
# -*- coding:utf-8 -*- class Solution: def Fibonacci(self, n): if n == 0: return 0 if n == 1: return 1 fn0 = 0 fn1 = 1 for i in range(2,n+1): curent = fn0 + fn1 fn0 = fn1 fn1 = curent return curent # write code here
相关文章推荐
- python剑指offer系列对称的二叉树
- 剑指offer系列之7:斐波那契数列
- python剑指offer系列滑动窗口的最大值
- python剑指offer系列复杂链表的复制
- python剑指offer系列第一个只出现一次的字符
- python剑指offer系列按之字形顺序打印二叉树
- python 实现剑指offer系列3:从尾到头打印链表
- python剑指offer系列二叉搜索树与双向链表
- python实现剑指offer系列:二维数组的查找
- 剑指Offer系列-面试题9:斐波那契数列
- python剑指offer系列树的子结构
- 《剑指offer》编程题java实现(六):斐波那契数列系列问题
- python 剑指offer系列:反转链表
- 【剑指offer系列】 斐波那契数列___9
- python剑指offer系列把二叉树打印成多行
- 剑指Offer:斐波那契数列系列
- 剑指offer系列之七:斐波那契数列
- python实现剑指offer系列2:字符串空格替换
- python剑指offer系列和为S的连续正数序列
- 剑指offer系列-T9_5斐波那契数列