计算阶乘:n! = 1*2*3*...n
#/usr/bin/env python def func(n): if n == 1: return 1 return n*func(n-1)
菲波那切数列:0,1,1,2,3,5,8,13,21,34......
#!/usr/bin/env python #-*- encoding:utf-8 -*- def func(n): if n == 0: return 0 if n == 1: return 1 else: resault = int(func(n-1))+int(func(n-2)) return resault n = raw_input("请输入你要输出fabonacci数列的第几位:\n") for i in range(n): print func(n)
本文出自 “挨刀客” 博客,请务必保留此出处http://chboy.blog.51cto.com/9959876/1930703
原文地址:http://chboy.blog.51cto.com/9959876/1930703