#include <stdio.h> #include <stdlib.h> int bf = 1; int cf = 2; int cn = 2; void fibo(int n){ int i, t; for (i = cn + 1; i <= n; i++){ t = cf; cf += bf; bf = t; } cn = n; } int isprime(int n){ int i; for (i = 2; i <= n / 2; i++){ if (n % i == 0) return 0; } return 1; } int main(void) { int i = 0, j = 0, n; printf("Cate numere prime din sirul lui Fibonacci doriti sa fie afisate="); scanf("%d", &n); if (n >= 0){ printf("%d\n", bf); j++; } while (j < n){ i++; fibo(i); if (isprime(cf)){ printf("%d\n", cf); j++; } } getch(); }