Skip to content

Instantly share code, notes, and snippets.

@swshan
Created July 21, 2017 08:50
Show Gist options
  • Save swshan/67495ed3ff0d0f7d05c80302084bd57c to your computer and use it in GitHub Desktop.
Save swshan/67495ed3ff0d0f7d05c80302084bd57c to your computer and use it in GitHub Desktop.
生成斐波那契数列并取前10项
def func(m):
n, a, b = 0, 1, 1
while n < m:
yield a
a, b = b, a+b
n = n + 1
def main():
for one in func(10):
print one
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment