prime_sieve()
```python
```python
def f(N):
if N <= 7: return 3
for d in prime_sieve(N)[::-1]:
k = d//2
while pow(10, k, d) != 1: k+= 1
if d-1 == k: return d
N = int(input('The longest recurring cycle for 1/d where d < '))
d = f(N)
print ("The longest repeating decimal for d < %d is 1/%d with %d repeating digits" % (N, d, (1 if N<8 else d-1)))
```