A307070 a(n) is the number of decimal places before the decimal expansion of 1/n terminates, or the period of the recurring portion of 1/n if it is recurring.
0, 1, 1, 2, 1, 1, 6, 3, 1, 1, 2, 1, 6, 6, 1, 4, 16, 1, 18, 2, 6, 2, 22, 1, 2, 6, 3, 6, 28, 1, 15, 5, 2, 16, 6, 1, 3, 18, 6, 3, 5, 6, 21, 2, 1, 22, 46, 1, 42, 2, 16, 6, 13, 3, 2, 6, 18, 28, 58, 1, 60, 15, 6, 6, 6, 2, 33, 16, 22, 6, 35, 1, 8, 3, 1, 18, 6, 6, 13
Offset: 1
Examples
1/1 is 1.0. There are no decimal digits, so a(1) = 0. 1/2 is 0.5. This is a terminating decimal. There is 1 digit, so a(2) = 1. 1/6 is 0.166666... This is a recurring decimal with a period of 1 (the initial '1' does not recur) so a(6) = 1. 1/7 is 0.142857142857... This is a recurring decimal, with a period of 6 ('142857') so a(7) = 6.
Crossrefs
Programs
-
PARI
a(n) = my (t=valuation(n,2), f=valuation(n,5), r=n/(2^t*5^f)); if (r==1, max(t,f), znorder(Mod(10, r))) \\ Rémy Sigrist, May 08 2019
-
Python
def sequence(n): count = 0 dividend = 1 remainder = dividend % n remainders = [remainder] no_recurrence = True while remainder != 0: count += 1 dividend = remainder * 10 remainder = dividend % n if remainder in remainders: if no_recurrence: no_recurrence = False remainders = [remainder] else: return len(remainders) else: remainders.append(remainder) else: return count
Extensions
More terms from Rémy Sigrist, May 08 2019
Comments