h. Ask the user how many terms he wants and print out the sequence below and sum of terms. 1 + 1 + 2 + 3 + 5 + 8 + ... 2 3 5 7 11 13 * above Fibonacci sequence and below sequence of Cousins.
I have this exercise to do, but I can not. When I play the two together, it changes everything. But if I do separate, I can make the sequence perfectly.
How to solve?
My code so far: link
#include "stdio.h"
main(){
int qtd, n1=0, n2=1, f=0, p=2, cont=0, j;
int a = 0;
printf("Entre com a quantidade de termos: ");
scanf("%d", &qtd);
for(int i=0; i<=qtd; i++){
cont=0;
for(j=1; j<=i; j++){
if (i%j==0){
cont++;
}
}
if(i!=0){
if(cont==2){
//printf("%d ", i);
printf("%d/%d + ", f, i);
}
}
/*if(i!=0){
printf("%d + ", f);
}*/
n1 = n2;
n2 = f;
f = n1+n2;
}
return 0;
}