Menu
Coddy logo textTech

Challenge #1

Lesson 21 of 23 in Coddy's C++ File Handling course.

challenge icon

Challenge

Medium

Write a program that takes 3 natural numbers from the input file input.txt and outputs every number from the Fibonacci sequence that is less than or equal to N each in a new line.

The Fibonacci sequence is the series of numbers as following: 1, 1, 2, 3, 5, 8, ...
The next number is found by adding up the two numbers before it.

Fn = Fn-1 + Fn-2

Input
4 9 6
Output
1 1 2 3
1 1 2 3 5 8
1 1 2 3 5

Try it yourself

#include <iostream>
#include <fstream>

using namespace std;
 
int main()
{
    
    // Enter your code here
 
    return 0;
}

All lessons in C++ File Handling