Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -8,30 +8,30 @@ PROC is semiprime = ( INT n )BOOL:
|
|||
# is semi prime #
|
||||
INT factor count := 0;
|
||||
FOR factor FROM 2 TO ENTIER sqrt( ABS n )
|
||||
WHILE IF n MOD factor = 0 THEN
|
||||
factor count +:= 1;
|
||||
# check the factor isn't a repeated factor #
|
||||
IF n /= factor * factor THEN
|
||||
# the factor isn't the square root #
|
||||
INT other factor = n OVER factor;
|
||||
IF other factor MOD factor = 0 THEN
|
||||
# have a repeated factor #
|
||||
factor count +:= 1
|
||||
FI
|
||||
FI
|
||||
FI;
|
||||
factor count < 2
|
||||
DO SKIP OD;
|
||||
WHILE factor count < 2 DO
|
||||
IF n MOD factor = 0 THEN
|
||||
factor count +:= 1;
|
||||
# check the factor isn't a repeated factor #
|
||||
IF n /= factor * factor THEN
|
||||
# the factor isn't the square root #
|
||||
INT other factor = n OVER factor;
|
||||
IF other factor MOD factor = 0 THEN
|
||||
# have a repeated factor #
|
||||
factor count +:= 1
|
||||
FI
|
||||
FI
|
||||
FI
|
||||
OD;
|
||||
factor count = 1
|
||||
END # is semiprime # ;
|
||||
|
||||
# determine the first few semi primes #
|
||||
print( ( "semi primes below 100: " ) );
|
||||
print( ( "semi primes below 100:", newline, " " ) );
|
||||
FOR i TO 99 DO
|
||||
IF is semi prime( i ) THEN print( ( whole( i, 0 ), " " ) ) FI
|
||||
IF is semi prime( i ) THEN print( ( " ", whole( i, 0 ) ) ) FI
|
||||
OD;
|
||||
print( ( newline ) );
|
||||
print( ( "semi primes below between 1670 and 1690: " ) );
|
||||
print( ( "semi primes between 1670 and 1690: " ) );
|
||||
FOR i FROM 1670 TO 1690 DO
|
||||
IF is semi prime( i ) THEN print( ( whole( i, 0 ), " " ) ) FI
|
||||
OD;
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
with Prime_Numbers, Ada.Text_IO;
|
||||
|
||||
procedure Test_Semiprime is
|
||||
|
||||
package Integer_Numbers is new
|
||||
Prime_Numbers (Natural, 0, 1, 2);
|
||||
use Integer_Numbers;
|
||||
|
||||
begin
|
||||
for N in 1 .. 100 loop
|
||||
if Decompose(N)'Length = 2 then -- N is a semiprime;
|
||||
Ada.Text_IO.Put(Integer'Image(Integer(N)));
|
||||
end if;
|
||||
end loop;
|
||||
Ada.Text_IO.New_Line;
|
||||
for N in 1675 .. 1680 loop
|
||||
if Decompose(N)'Length = 2 then -- N is a semiprime;
|
||||
Ada.Text_IO.Put(Integer'Image(Integer(N)));
|
||||
end if;
|
||||
end loop;
|
||||
end Test_Semiprime;
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
function isPrime ($n) {
|
||||
if ($n -le 1) {$false}
|
||||
elseif (($n -eq 2) -or ($n -eq 3)) {$true}
|
||||
else{
|
||||
$m = [Math]::Floor([Math]::Sqrt($n))
|
||||
(@(2..$m | where {($_ -lt $n) -and ($n % $_ -eq 0) }).Count -eq 0)
|
||||
}
|
||||
}
|
||||
function semiprime ($n) {
|
||||
if($n -gt 3) {
|
||||
$lim = [Math]::Floor($n/2)+1
|
||||
$i = 2
|
||||
while(($i -lt $lim) -and ($n%$i -ne 0)){ $i += 1}
|
||||
if($i -eq $lim){@()}
|
||||
elseif(-not (isPrime ($n/$i))){@()}
|
||||
else{@($i,($n/$i))}
|
||||
} else {@()}
|
||||
}
|
||||
$OFS = " x "
|
||||
"1679: $(semiprime 1679)"
|
||||
"87: $(semiprime 87)"
|
||||
"25: $(semiprime 25)"
|
||||
"12: $(semiprime 12)"
|
||||
"6: $(semiprime 6)"
|
||||
$OFS = " "
|
||||
"semiprime from 1 to 100: $(1..100 | where {semiprime $_})"
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
include Settings
|
||||
-- 24 Aug 2025
|
||||
include Setting
|
||||
|
||||
say 'SEMIPRIME - 4 Mar 2025'
|
||||
say 'SEMIPRIME'
|
||||
say version
|
||||
say
|
||||
numeric digits 100
|
||||
|
|
@ -30,7 +31,4 @@ say Format(Time('e'),,3) 'seconds'
|
|||
say
|
||||
return
|
||||
|
||||
include Functions
|
||||
include Numbers
|
||||
include Sequences
|
||||
include Abend
|
||||
include Math
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue