1 | #!/usr/bin/env python2
|
2 | """
|
3 | fib.py
|
4 | """
|
5 | from __future__ import print_function
|
6 |
|
7 | import sys
|
8 |
|
9 |
|
10 | def main(argv):
|
11 | try:
|
12 | iters = int(argv[1])
|
13 | except IndexError:
|
14 | iters = 5
|
15 |
|
16 | try:
|
17 | n = int(argv[2])
|
18 | except IndexError:
|
19 | n = 10
|
20 |
|
21 | i = 0
|
22 | while i < iters:
|
23 | j = 0
|
24 | a = 1
|
25 | b = 1
|
26 |
|
27 | while j < n:
|
28 | a, b = b, a+b
|
29 | j += 1
|
30 |
|
31 | print(b)
|
32 |
|
33 | i += 1
|
34 |
|
35 |
|
36 | if __name__ == '__main__':
|
37 | try:
|
38 | main(sys.argv)
|
39 | except RuntimeError as e:
|
40 | print('FATAL: %s' % e, file=sys.stderr)
|
41 | sys.exit(1)
|