begin
var n := ReadlnString.ToBigInteger;
var Count := BigInteger(0);
var Max := Biginteger(n);
while n <> 1 do
if n.IsEven then
n := n div 2;
Count += n
end
else
n += 2 * n + 1;
if Max < n then
Max := n
end;
Print(Count, Max);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
begin
var n := ReadlnString.ToBigInteger;
var Count := BigInteger(0);
var Max := Biginteger(n);
while n <> 1 do
begin
if n.IsEven then
begin
n := n div 2;
Count += n
end
else
begin
n += 2 * n + 1;
if Max < n then
Max := n
end
end;
Print(Count, Max);
end.