Fibonacci series

Enter the value of X: 37
Fibonacci Series between 0 and 37 are: 0, 1, 1, 3, 5, 8, 13, 21, 34

i cant write the code for this problem. pls help.......
See the sticky on how to ask questions on this forum, please.
Well, first number is 0, second number is 1. Third number is first plus second, fourth is second plus third, et cetera.

If you know the number that you want to go up to, you can use a vector. If you know specifically how many numbers (such as the first 37) you can use a dynamic array. Depending on the method, you can either use the array's index to have array[i+2] = array[i+1] + array[i]. If using a vector, set the iterator to the last position, then emplace_back a new value that is equal to the last value plus the value immediately before the last value.
Topic archived. No new replies allowed.