project-euler

Reciprocal cycles

Problem Description

A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given:

Where 0.1(6) means 0.166666…, and has a 1-digit recurring cycle. It can be seen that 1/7 has a 6-digit recurring cycle.

Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.

Performance

Try it online!

Real time: 5.300 s
User time: 5.184 s
Sys. time: 0.121 s
CPU share: 100.10 %
Exit code: 0