diff --git a/projecteuler/071/main.cpp b/projecteuler/071/main.cpp new file mode 100644 index 0000000..907f03c --- /dev/null +++ b/projecteuler/071/main.cpp @@ -0,0 +1,42 @@ +/* + +Ordered Fractions + +Consider the fraction, n/d, where n and d are positive integers. If n + +using namespace std; + +const int MAX = 1000000; + +int main(){ + + cout << "Hello this is Patrick" << endl; + auto start = chrono::high_resolution_clock::now(); + + long a = 3, b = 7, r = 0, s = 1; + for(int q = MAX; q > 2; q--){ + long p = (a * q - 1) / b; + if(p * s > r * q){ + s = q; + r = p; + } + } + + cout << r << " / " << s << endl; + + auto duration = chrono::duration_cast(chrono::high_resolution_clock::now() - start); + cout << (float)duration.count()/1000 << endl; + return 0; +}