Initially I was developing a python code that would help me better understand Nikola Tesla's Number Theory ( video ).
Explaining quickly, starting with 360, adding each separate value results in 9, for example: 3 + 6 + 0 = 9, always dividing the value 360 by 2, adding the separated numbers always results in 9, for example: 360 / 2 = 180, 1 + 8 + 0 = 9 180/2 = 90 9 + 0 = 9 And so on
Initially the base code I made was this in python
real_valor=360 ; string_valor=str(real_valor); valor_unitario=[]; soma_unitaria=0
for i in string_valor:
if i == '.':
continue
valor_unitario.append(int(i))
print(valor_unitario)
for g in valor_unitario:
soma_unitaria += g
print(soma_unitaria)
Using the first as base, conclude this one:
soma_unitaria=0; from time import sleep
while True:
sleep(0.5)
if soma_unitaria == 0:
real_valor = 360; string_valor = str(real_valor); valor_unitario = []
else:
string_valor='';soma_unitaria = 0; real_valor /= 2; string_valor = (str(real_valor)); valor_unitario.clear()
for numero in string_valor:
if numero == '.':
continue
valor_unitario.append(int(numero))
for valor in valor_unitario:
soma_unitaria += valor
print("Valor Inicial : {}\nSoma dos valores unitarios divido : {}\n".format(real_valor, soma_unitaria))
The code works initially. The problem starts after many decimal places, I can not convert the value that the floats assign to float or int (the values are initially in string so I can separate them one by one and can add them together)
Error line 11
How can I solve this problem, many decimal places end up adding the value and, in strings I can not convert to numbers?