Created
July 21, 2017 08:50
-
-
Save swshan/67495ed3ff0d0f7d05c80302084bd57c to your computer and use it in GitHub Desktop.
生成斐波那契数列并取前10项
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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