Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ### Project Euler, problem 216 ### */
- /* Notice that I'm not the best C programmer ever :D */
- #include <stdio.h>
- #include <tgmath.h>
- #define MAX 50000000
- short isPrime(unsigned long n) {
- int i;
- for(i=2; i<=(unsigned long) trunc(sqrt((double) n)); ++i)
- if (n % i == 0) return 0;
- return 1;
- }
- unsigned long t(unsigned long n){
- return 2 * n*n - 1;
- }
- int main(void) {
- unsigned long i, count=0;
- for(i=2; i<=MAX; ++i)
- if (isPrime(t(i)))
- ++count;
- printf("%lu", count);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment