/* Consider the fraction, n/d, where n and d are positive integers. If n #include #include #include "projecteuler.h" #define N 1000000 int main(int argc, char **argv) { int i, j, n, d, max_n; double elapsed, max = 0.0; struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); /* For each denominator q, we need to find the biggest numerator p for which * p/q max) { n = j; d = i; max = (double)n / d; /* Reduce the fraction if it's not already reduced.*/ if(gcd(i, j) > 1) { n /= gcd(i, j); d /= gcd(i, j); } max_n = n; } } clock_gettime(CLOCK_MONOTONIC, &end); elapsed = (end.tv_sec - start.tv_sec) + (double)(end.tv_nsec - start.tv_nsec) / 1000000000; printf("Project Euler, Problem 71\n"); printf("Answer: %d\n", max_n); printf("Elapsed time: %.9lf seconds\n", elapsed); return 0; }