#include <iostream>
using namespace std;
int main(){
// f_n = f_n1 + f_n2
int n;
int f_n;
int f_n1;
int f_n2;
cout << "Program Deret Fibonaci \n";
cout << "Masukan nilai ke-n: ";
cin >> n;
cout << "\n";
f_n1 = 1;
f_n2 = 0;
cout << f_n2 << " ";
cout << f_n1 << " ";
for(int i = 1; i < n; i++){
f_n = f_n1 + f_n2;
f_n2 = f_n1;
f_n1 = f_n;
cout << f_n << " ";
}
cout << "\n";
}
To embed this project on your website, copy the following code and paste it into your website's HTML: