Data update

This commit is contained in:
Ingy dot Net 2024-04-19 16:56:29 -07:00
parent 0df55f9f24
commit aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions

View file

@ -1,40 +1,40 @@
/*REXX program finds and displays N number of anti─primes or highly─composite numbers.*/
parse arg N . /*obtain optional argument from the CL.*/
if N=='' | N=="," then N= 20 /*Not specified? Then use the default.*/
maxD= 0 /*the maximum number of divisors so far*/
say 'index antiprime' /*display a title for the numbers shown*/
#= 0 /*the count of anti─primes found " " */
do once=1 for 1
do i=1 for 59 /*step through possible numbers by twos*/
d= #divs(i); if d<=maxD then iterate /*get # divisors; Is too small? Skip.*/
#= # + 1; maxD= d /*found an anti─prime #; set new minD.*/
say center(#, 7) right(i, 10) /*display the index and the anti─prime.*/
if #>=N then leave once /*if we have enough anti─primes, done. */
end /*i*/
/*REXX program finds and displays N number of anti-primes (highly-composite) numbers.*/
Parse Arg N . /* obtain optional argument from the CL. */
If N=='' | N=="," Then N=20 /* Not specified? Then use the default. */
maxD=0 /* the maximum number of divisors so far */
Say '-index- --anti-prime--' /* display a title For the numbers shown */
nn=0 /* the count of anti-primes found " " */
Do i=1 For 59 While nn<N /* step through possible numbers by twos */
d=nndivs(i) /* get nn divisors; */
If d>maxD Then Do /* found an anti-prime nn set new maxD */
maxD=d
nn=nn+1
Say center(nn,7) right(i,10) /* display the index and the anti-prime. */
End
End /*i*/
do j=60 by 20 /*step through possible numbers by 20. */
d= #divs(j); if d<=maxD then iterate /*get # divisors; Is too small? Skip.*/
#= # + 1; maxD= d /*found an anti─prime #; set new minD.*/
say center(#, 7) right(j, 10) /*display the index and the anti─prime.*/
if #>=N then leave /*if we have enough anti─primes, done. */
end /*j*/
end /*once*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
#divs: procedure; parse arg x 1 y /*X and Y: both set from 1st argument.*/
if x<3 then return x /*handle special cases for one and two.*/
if x==4 then return 3 /* " " " " four. */
if x<6 then return 2 /* " " " " three or five*/
odd= x // 2 /*check if X is odd or not. */
if odd then #= 1 /*Odd? Assume Pdivisors count of 1.*/
else do; #= 3; y= x % 2 /*Even? " " " " 3.*/
end /* [↑] start with known num of Pdivs.*/
do k=3 for x%2-3 by 1+odd while k<y /*for odd numbers, skip evens.*/
if x//k==0 then do; #= # + 2 /*if no remainder, then found a divisor*/
y= x % k /*bump # Pdivs, calculate limit Y. */
if k>=y then do; #= # - 1; leave; end /*limit?*/
end /* ___ */
else if k*k>x then leave /*only divide up to √ x */
end /*k*/ /* [↑] this form of DO loop is faster.*/
return #+1 /*bump "proper divisors" to "divisors".*/
Do i=60 by 20 While nn<N /* step through possible numbers by 20. */
d=nndivs(i)
If d>maxD Then Do /* found an anti-prime nn set new maxD */
maxD=d
nn=nn+1
Say center(nn,7) right(i,10) /* display the index and the anti-prime. */
End
End /*i*/
Exit /* stick a fork in it, we're all done. */
/*-----------------------------------------------------------------------------------*/
nndivs: Procedure /* compute the number of proper divisors */
Parse Arg x
If x<2 Then
Return 1
odd=x//2
n=1 /* 1 is a proper divisor */
Do j=2+odd by 1+odd While j*j<x /* test all possible integers */
/* up To but excluding sqrt(x) */
If x//j==0 Then /* j is a divisor,so is x%j */
n=n+2
End
If j*j==x Then /* If x is a square */
n=n+1 /* sqrt(x) is a proper divisor */
n=n+1 /* x is a proper divisor */
Return n