In python
Write and test code to compute (and write out) the first nFibonacci numbers (starting with 0), as determined by integers (oneper line) in an input file.
Suggested algorithm:
Open a file 4numsin.txt for input containing acollection of integers (one per line)
Open a file 4numsout.txt for output.
Read each integer n from your input file andwrite out the first n Fibonacci numbers (separated by spaces) tothe next line of your output file
Solution
def fibonacci(n): if n==1: return 0 elif n<=3: return 1
OR
OR