Hello I am a beginner in Python. I wrote the following code to convert a number in to a bynary number. I use T to count how many times the number can be devide by two. The remainder R is used again in the inner loop, but then I have to set T to 0, if I do this I get in to an infinite loop .... Can someone help me with this?
import math
T=0 # timer to count homany times the given number can be divided by 2
G= int(input("nummer "))
A=G # save G in A, we need G later
R=G # the remainder also initialized with G
while R>1:
print(T)
while A>1:
A=int(A/2)
T=T+1
print(T)
print(A)
R=int(G-math.pow(2,T))
A=R #use the remainder agin in the inner loop
T=0 #set T to O, here it goes wrong, ill get an infinite loop!!! why