1.dengan c++
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int fibonacci(int n){
if (n==1 || n==2)return(1);
else return(fibonacci(n-1)+fibonacci(n-2));
}
int main(int argc, char** argv) {
int i,n;
cout<<"Masukan Batas Suku =";cin>>n;
for(i=1;i<=n;i++)
cout<<fibonacci(i)<<",";
return 0;
}
2.dengan raptor
Tidak ada komentar:
Posting Komentar