-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem026.py
41 lines (40 loc) · 1.59 KB
/
problem026.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def main(N):
lookup = {}
for number in range(2,N+1):
divisor = number
periodic_number = []
rest_number = []
dividendo = 10
resto = 0
while (resto not in rest_number) or (dividendo!=0):
if dividendo < divisor:
if dividendo == 0:
break
else:
dividendo = dividendo * 10
if dividendo < divisor:
periodic_number.append(0)
else:
cociente = dividendo // divisor
resto = dividendo % divisor
dividendo = resto
if resto not in rest_number:
periodic_number.append(cociente)
rest_number.append(resto)
else:
break
else:
if dividendo!=0:
cociente = dividendo // divisor
resto = dividendo % divisor
dividendo = resto
periodic_number.append(cociente)
rest_number.append(resto)
else:
print("Se termino la operacion")
lookup[number] = periodic_number
clave_con_max_longitud = max(lookup, key=lambda clave: len(lookup[clave]))
print(f"El numero entre 2 y 1000 con la secuencia más grande de decimales es: {clave_con_max_longitud}")
print(f"Su secuencia es: {lookup[clave_con_max_longitud]}")
return lookup
response = main(1000) # 983