diff options
author | Santo Cariotti <sancn@live.com> | 2017-04-23 19:43:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-23 19:43:32 +0200 |
commit | e1d76dd1d6e9cd35a17e6443d7222a9499ccc698 (patch) | |
tree | 5b8df0d8e293a0f280bfd30f6105c95a987ef5fd | |
parent | 8317eb9cae7ff46e400534572542496fef508cfc (diff) |
Update lswf.py
-rw-r--r-- | lswf.py | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -1,23 +1,20 @@ fib = [1, 1] -lst = 0 def fibonacci(N): - global lst for i in range(2, N): fib.append(fib[i - 1] + fib[i - 2]) - lst = i + if fib[i] > N: break + + return i with open('input.txt', 'r') as fin: N = int(fin.readline()) -fibonacci(N) - -for i in fib: - print(i, end=' ') +lst = fibonacci(N) fib.reverse() print() @@ -40,4 +37,4 @@ if N == 1 or N > 4: with open('output.txt', 'w') as fout: for i in seq: - fout.write(str(i))
\ No newline at end of file + fout.write(str(i)) |