I need to develop an algorithm where it divides a number by 2 until it reaches the rest of the division, and I need to know if the rest of this division is an integer, what method can I apply to develop this problem?
where:
funcao menu_8():inteiro
var
inicio
para contador de 0 ate 12 faca
se (i[contador] % 2 = 1) entao
escreva (" Potencia de 2: ", i[contador])
fimse
fimpara
escreval(" ")
fimfuncao
This algorithm will be applied, in the following, if the user type in the vector, a number that is power of 2, should display this value.
Where will I use Base Log 10 to divide the number entered by 2 log of 10, and if the result of dividing an integer, ai means that base is two, the number entered by the user, if otherwise it is not.