|
|
back to boardWhy my program wrong anser Posted by Oleg 21 Oct 2002 09:27 var n:longint; function sum(i:longint):longint; begin if i<2 then sum:=i else begin if (i mod 2)=0 then sum:=sum(i div 2) else sum:=sum(i div 2)+sum(1+(i div 2)); end; end; begin repeat read(n); if n>0 then writeln(sum(n)); until n=0; end. |
|
|