기본적으로이 문제는 끝납니다. 유일한 문제는 소수가 있는지 확인하기 위해 루프를 돌릴 때 피보나치 시퀀스에없는 소수를 출력하는 것입니다.Fibonacci Prime을 조건부로 확인하십시오.
int main()
{
int no1,no2,newno,pno,i,terms,j;
no1 = 0;
no2 = 1;
printf("**Fibonacci and Prime Numbers**\n\n");
printf("Enter number of terms: \n");
scanf("%d", &terms);
printf("\nAmong the first %d terms of Fibonacci series that are also prime number: \n", terms);
for(i=0; i<terms; i++){
if(i<=no2){
newno = i;
}
else{
newno = no1+no2;
no1 = no2;
no2 = newno;
}
}
for(pno=2;pno<=newno;pno++){
for(j=2;j<=pno;j++){
if(pno%j==0){
break;
}
}
if(pno==j){
printf("%d \n", pno);
}
}
getch();
return 0;
}
나는 그것 때문에 pno++
의 추측하고있어 내가 바로, AM : 여기 내 코드는?
나는 그것을 시도하고 그것이 작동하지 않는다, 지금 그것은 하나의 번호 또는 전혀 번호를 인쇄합니다. 그것은 단지 우리의 입력 전에 번호를 인쇄합니다 (숫자가 소수 일 경우 피보나치) – Ned