Jump to content

Isqrt (integer square root) of X: Difference between revisions

→‎{{header|Raku}}: Add thousands separators as required by task description.k
(→‎{{header|UNIX Shell}}: Add thousands separator.)
(→‎{{header|Raku}}: Add thousands separators as required by task description.k)
Line 2,930:
 
Quadratic residue algorithm follows:
<lang perl6>use Lingua::EN::Numbers;
<lang perl6>sub isqrt ( \x ) { my ( $X, $q, $r, $t ) = x, 1, 0 ;
$q +<= 2 while $q ≤ $X ;
while $q > 1 {
Line 2,941 ⟶ 2,942:
say (^66)».&{ isqrt $_ }.Str ;
 
(1, 3…73)».&{ "7**$_: " ~ comma(isqrt 7**$_) }».say</lang>
{{out}}
<pre>0 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8
7**1: 2
7**3: 18
7**5: 129
7**7: 907
7**9: 63526,352
7**11: 4446744,467
7**13: 311269311,269
7**15: 21788892,178,889
7**17: 1525222915,252,229
7**19: 106765608106,765,608
7**21: 747359260747,359,260
7**23: 52315148225,231,514,822
7**25: 3662060375836,620,603,758
7**27: 256344226312256,344,226,312
7**29: 17944095841841,794,409,584,184
7**31: 1256086708929112,560,867,089,291
7**33: 8792606962504087,926,069,625,040
7**35: 615482487375282615,482,487,375,282
7**37: 43083774116269774,308,377,411,626,977
7**39: 3015864188138884230,158,641,881,388,842
7**41: 211110493169721897211,110,493,169,721,897
7**43: 14777734521880532811,477,773,452,188,053,281
7**45: 1034441416531637297310,344,414,165,316,372,973
7**47: 7241089915721461081272,410,899,157,214,610,812
7**49: 506876294100502275687506,876,294,100,502,275,687
7**51: 3,548,134,058,703,515,929,815
7**51: 3548134058703515929815
7**53: 24,836,938,410,924,611,508,707
7**53: 24836938410924611508707
7**55: 173,858,568,876,472,280,560,953
7**55: 173858568876472280560953
7**57: 1,217,009,982,135,305,963,926,677
7**57: 1217009982135305963926677
7**59: 8,519,069,874,947,141,747,486,745
7**59: 8519069874947141747486745
7**61: 59,633,489,124,629,992,232,407,216
7**61: 59633489124629992232407216
7**63: 417,434,423,872,409,945,626,850,517
7**63: 417434423872409945626850517
7**65: 2,922,040,967,106,869,619,387,953,625
7**65: 2922040967106869619387953625
7**67: 20,454,286,769,748,087,335,715,675,381
7**67: 20454286769748087335715675381
7**69: 143,180,007,388,236,611,350,009,727,669
7**69: 143180007388236611350009727669
7**71: 1,002,260,051,717,656,279,450,068,093,686
7**71: 1002260051717656279450068093686
7**73: 7,015,820,362,023,593,956,150,476,655,802</pre>
7**73: 7015820362023593956150476655802
</pre>
 
=={{header|REXX}}==
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.