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

123456789101112131415161718192021222324252627282930
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3. #include <limits.h>
  4. #define typ long long int
  5. bool foo(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 fn = 0, fn_1 = 1, fn_2 = 0;
  16. printf("%llu",ULONG_MAX);
  17. while(fn < ULONG_MAX)
  18. {
  19. fn = (typ)fn_1 + (typ)fn_2;
  20. if(foo(&fn))
  21. printf("%llu\n",fn);
  22. fn_2 = fn_1;
  23. fn_1 = fn;
  24. }
  25. return 0;
  26. }