mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Programming (https://www.mersenneforum.org/forumdisplay.php?f=29)
-   -   algorithm for factoring a number into two factors (https://www.mersenneforum.org/showthread.php?t=23380)

irina 2018-05-28 13:55

algorithm for factoring a number into two factors
 
var k,l,n,s,j,d,c,y,r,b:biginteger;
begin
var x:=ReadString('введите число:').ToBigInteger;
var a:=x div 2;
repeat
b:=a;
a:=(a+x div a)div 2
until a>=b;
s:=a;
n:=x-sqr(s);
k:=n div s; j:=n mod s; l:=s+k; d:= s-j;
repeat
s:=s-1;
d:=d-1;
r:=l-d;
c:=r div s;
y:=r mod s;
l:=l+1+c;
j:=y;
d:=s-j;
until j=0;
writeln('l=',l); writeln ('s=',s);
end.


All times are UTC. The time now is 07:25.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.