4
I need to develop an algorithm where, it divides a number by 2, until I get to 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 on screen.
Where will I use, Base Log 10, to divide the number typed by 2 log of 10, and if the result of the division of an integer number, ai means it is base of two, the number typed by the user, otherwise it is not.
This works on Visualg in portugol??
– Maurício Z.B
@Mauricio probably needs some adaptation.
– Maniero