Question 5 - 15th Term in Fibonacci Series
itsLu
c_cpp
2 years ago
334 B
28
Indexable
// 5. Write a program to print term 15 from the series 1, 1, 2, 3, 5
#include <iostream>
using namespace std;
int main ()
{
int x = 1, y = 1, temp;
for (int k = 2 ; k < 15 ; k++)
{
temp = x;
x = y;
y = temp;
y += x; //or y = x + y;
}
cout << "15th Term = " << y;
}
Editor is loading...
Leave a Comment