summaryrefslogtreecommitdiff
path: root/lswf.py
diff options
context:
space:
mode:
Diffstat (limited to 'lswf.py')
-rw-r--r--lswf.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/lswf.py b/lswf.py
index 29d58b2..cc51cb7 100644
--- a/lswf.py
+++ b/lswf.py
@@ -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))