Intersection of fibonacci sequence and prim numbers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

prim.c 366B

1234567891011121314151617181920212223242526272829
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #define typ unsigned long long
  4. bool is_it_a_prim(typ* x){
  5. int k = 2;
  6. while(k < *x){
  7. if(*x % k == 0)
  8. return false;
  9. k++;
  10. }
  11. return true;
  12. }
  13. int main(void){
  14. typ int fn = 0, fn_1 = 1, fn_2 = 0;
  15. for(int i=0;i<700;i++)
  16. {
  17. fn = fn_1 + fn_2;
  18. if(is_it_a_prim(&fn))
  19. printf("%llu\n",fn);
  20. fn_2 = fn_1;
  21. fn_1 = fn;
  22. }
  23. getchar();
  24. return 0;
  25. }