For practice 2
Submit solution
C, C++, Python3
Points:
1
Time limit:
1.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
This practice problem will require you to programme basic for
loops.
Your task is to print the Fibonacci number sequence without using arrays.
The Fibonacci series starts with a[0]=1
and a[1]=1
, and after that
a[i]=a[i-2] + a[i-1]
.
You are expected to print the sequence of all Fibonacci numbers less than a
given input N
.
Input Specification
The input contains a single line with a single integer N
(\(1 < N < 1000000000\)).
Output Specification
The first and second lines should contain only a single 1
.
Then, each line should contain a single integer which is the next
Fibonacci number.
Sample Input
10
Sample Output
1
1
2
3
5
8
Comments
Consider the following bare-bone code:
Can you figure out a way to ONLY modify the for loop condition to solve this task? Please try.