counter = 0
x = int(input("Введите число: "))
while x != 2 and x != 1:
counter += 1
x /= 2
if x == 1:
print(0)
else:
print(counter+1)
const
MAX = 20;
var
s:string;
stack:array[1..MAX] of string;
top:integer;
i:byte;
procedure Push(ch:string);
begin
if top>=MAX then WriteLn('Stask full')
else
begin
stack[top]:=ch;
top:=top+1;
end;
end;
function Pop:string;
begin
top:=top-1;
if top<1 then
begin
WriteLn('Stack underflow');
top:=top+1;
end
else Pop := stack[top];
end;
begin
top:=1;
s:='<asdf<asdf>asdf>';//правильная строка
for i:=1 to length(s) do
begin
if s[i]='<' then Push('<');
if s[i]='>' then
if Pop()<>'<' then WriteLn('Ошибка!');
end;
if top<>1 then WriteLn('Ошибка!');
top:=1;
s:='<asdf<asdfasdf>';//не правильная строка
for i:=1 to length(s) do
begin
if s[i]='<' then Push('<');
if s[i]='>' then
if Pop()<>'<' then WriteLn('Ошибка!');
end;
if top<>1 then WriteLn('Ошибка!');
end.
Объяснение:
number = input () #Ввод
n = input() #Ввод степени
result = 0
int(n)
int(number) #Вместо строчной переменной создаём числовую
while result<10:
number * n
print (number)