We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Solved this problem in F#. My O(n log n) solution was apparently not fast enough for all test cases, so I had to use a precalculated solution to pass all tests.
The only smart trick I used was to exploit phi(m*n) = phi(m)*phi(n) if m and n are relatively prime. This speeds up the phi calculations.
Project Euler #70: Totient permutation
You are viewing a single comment's thread. Return to all comments →
Solved this problem in F#. My O(n log n) solution was apparently not fast enough for all test cases, so I had to use a precalculated solution to pass all tests. The only smart trick I used was to exploit phi(m*n) = phi(m)*phi(n) if m and n are relatively prime. This speeds up the phi calculations.