|
|
back to boardvar i,n,l,j:longword; found:boolean; begin readln(n); repeat found:=False; for j:=3 to n div 2 do begin if n mod j=0 then begin found:=True; break; end; end; if found then n:=j; until not found; writeln(n-1); readln; end. Please help me to optimize my code. It's 0.405 sec for j := 3 to sqrt(n) do will help you :) > for j := 3 to sqrt(n) do will help you :) will it? for sqrt(8) = 2.8, but answer should be 4 - 1 = 3 |
|
|