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 376B

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