Fibonacci Numbers
Lesson 14 of 32 in Coddy's Coding Problems course.
Create a program that will output every Fibonacci number that is less than or equal to a given number N.
Challenge
MediumWrite a program that gets a natural number N from input and outputs every number from the Fibonacci sequence that is less than or equal to N.
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
3
Output
1 1 2 3
Input
6
Output
1 1 2 3 5
Try it yourself
#include <stdio.h>
int main() {
// Write code here
return 0;
}
All lessons in Coding Problems
1Course Introduction
Introduction3Medium Difficulty
Candy BarsFibonacci NumbersFactorialNumber of digitsLeast common multipleLargest sumNotebookApplesGiftsDog yearsAnagrams