Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
53
Task/Blum-integer/AWK/blum-integer.awk
Normal file
53
Task/Blum-integer/AWK/blum-integer.awk
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# syntax: GAWK -f BLUM_INTEGER.AWK
|
||||
# converted from FutureBasic
|
||||
#
|
||||
# sorting:
|
||||
# PROCINFO["sorted_in"] is used by GAWK
|
||||
# SORTTYPE is used by Thompson Automation's TAWK
|
||||
#
|
||||
BEGIN {
|
||||
n = 3
|
||||
prime2 = 0
|
||||
print("The first 50 Blum integers:")
|
||||
while (1) {
|
||||
if (is_semiprime(n)) {
|
||||
if (prime1 % 4 == 3) {
|
||||
prime2 = n / prime1
|
||||
if ((prime2 != prime1) && (prime2 % 4 == 3)) {
|
||||
arr[substr(n,length(n),1)]++
|
||||
total++
|
||||
if (++count <= 50) {
|
||||
printf("%4d%s",n,count%10?"":"\n")
|
||||
}
|
||||
if (count ~ /^(26828|[1-4]00000)$/) {
|
||||
printf("\nThe %6dth Blum integer: %7d",count,n)
|
||||
if (count >= 400000) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
n += 2
|
||||
}
|
||||
PROCINFO["sorted_in"] = "@ind_num_asc" ; SORTTYPE = 1
|
||||
printf("\n\nFor Blum integers up to %d:\n",count)
|
||||
for (i in arr) {
|
||||
printf("%7.3f%% end in %d\n",arr[i]/total*100,i)
|
||||
}
|
||||
exit(0)
|
||||
}
|
||||
function is_semiprime(n, c,d) {
|
||||
c = 0
|
||||
d = 3
|
||||
while (d * d <= n) {
|
||||
while (n % d == 0) {
|
||||
if (c == 2) { return(0) }
|
||||
n /= d
|
||||
c++
|
||||
}
|
||||
d += 2
|
||||
}
|
||||
prime1 = n
|
||||
return(c == 1)
|
||||
}
|
||||
89
Task/Blum-integer/Ada/blum-integer.adb
Normal file
89
Task/Blum-integer/Ada/blum-integer.adb
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
|
||||
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
|
||||
|
||||
procedure Blum is
|
||||
|
||||
Inc : Constant array (1 .. 8) of Integer := (4, 2, 4, 2, 4, 6, 2, 6);
|
||||
|
||||
function Is_Prime (N : Integer) return Boolean is
|
||||
D : Integer := 5;
|
||||
begin
|
||||
if N < 2 then return False; end if;
|
||||
if N mod 2 = 0 then return N = 2; end if;
|
||||
if N mod 3 = 0 then return N = 3; end if;
|
||||
|
||||
while D * D <= N loop
|
||||
if N mod D = 0 then return False; end if;
|
||||
D := D + 2;
|
||||
if N mod D = 0 then return False; end if;
|
||||
D := D + 4;
|
||||
end loop;
|
||||
|
||||
return True;
|
||||
end Is_Prime;
|
||||
|
||||
function First_Prime_Factor (N : Integer) return Integer is
|
||||
D : Integer := 7;
|
||||
I : Integer := 1;
|
||||
begin
|
||||
if N = 1 then return 1; end if;
|
||||
if N mod 3 = 0 then return 3; end if;
|
||||
if N mod 5 = 0 then return 5; end if;
|
||||
|
||||
while D * D <= N loop
|
||||
if N mod D = 0 then
|
||||
return D;
|
||||
end if;
|
||||
D := D + Inc(I);
|
||||
I := (I mod 8) + 1;
|
||||
end loop;
|
||||
|
||||
return N;
|
||||
end First_Prime_Factor;
|
||||
|
||||
I, Blum_Count : Integer := 1;
|
||||
J, P, Q : Integer;
|
||||
Blums : Array (1 .. 50) of Integer;
|
||||
Counts : Array (1 .. 4) of Integer := (others => 0);
|
||||
Final_Digits : Array (1 .. 4) of Integer := (1, 3, 7, 9);
|
||||
|
||||
begin
|
||||
loop
|
||||
P := First_Prime_Factor(I);
|
||||
if P mod 4 = 3 then
|
||||
Q := I / P;
|
||||
if Q /= P and Q mod 4 = 3 and Is_Prime(Q) then
|
||||
if Blum_Count < 51 then Blums(Blum_Count) := I; end if;
|
||||
Counts(((I mod 10) / 3) + 1) := Counts(((I mod 10) / 3) + 1) + 1;
|
||||
Blum_Count := Blum_Count + 1;
|
||||
if Blum_Count = 51 then
|
||||
Put("First 50 Blum Integers:"); New_Line;
|
||||
for J in Integer range 1 .. 50 loop
|
||||
Put(Item => Blums(J), Width => 3); Put(" ");
|
||||
if J mod 10 = 0 then New_Line; end if;
|
||||
end loop;
|
||||
New_Line;
|
||||
elsif Blum_Count = 26829 or Blum_Count mod 100000 = 1 then
|
||||
Put("The "); Put(Item => Blum_Count, Width => 7);
|
||||
Put("th Blum Integer is: "); Put(Item => I, Width => 9);
|
||||
New_Line;
|
||||
if Blum_Count = 400001 then
|
||||
New_Line; Put("% Distribution of the First 400,000 Blum Integers:"); New_Line;
|
||||
for J in Integer range 1 .. 4 loop
|
||||
Put(" "); Put(Item => Float(Counts(J)) / 4000.0, Fore => 2, Aft => 3, Exp => 0);
|
||||
Put("% end in "); Put(Item => Final_Digits(J), Width => 1);
|
||||
New_Line;
|
||||
end loop;
|
||||
exit;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
end if;
|
||||
if I mod 5 = 3 then
|
||||
I := I + 4;
|
||||
else
|
||||
I := I + 2;
|
||||
end if;
|
||||
end loop;
|
||||
end Blum;
|
||||
17
Task/Blum-integer/Arturo/blum-integer.arturo
Normal file
17
Task/Blum-integer/Arturo/blum-integer.arturo
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
blum?: function [n][
|
||||
if any? @[n < 21, even? n, zero? n % 5]
|
||||
-> return false
|
||||
|
||||
f: factors.prime n
|
||||
if or? [2 <> size f][f\0 = f\1]
|
||||
-> return false
|
||||
|
||||
every? f => [3 = & % 4]
|
||||
]
|
||||
|
||||
print "First 50 Blum numbers:"
|
||||
1..∞ | select.first: 50 => blum?
|
||||
| split.every: 10
|
||||
| loop => [print map & 'x -> pad to :string x 4]
|
||||
|
||||
print ["\n26828th Blum number:" select.n:26828 1..∞ => blum?]
|
||||
27
Task/Blum-integer/Frink/blum-integer.frink
Normal file
27
Task/Blum-integer/Frink/blum-integer.frink
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
isBlum = {|x|
|
||||
f = factorFlat[x]
|
||||
if length[f] != 2
|
||||
return false
|
||||
|
||||
f1 = first[f]
|
||||
f2 = last[f]
|
||||
return (f1 != f2) and (first[f] mod 4 == 3) and (last[f] mod 4 == 3)
|
||||
}
|
||||
|
||||
println["First 50:"]
|
||||
println[first[select[count[1], isBlum], 50]]
|
||||
|
||||
ret = new array
|
||||
for n = [26828, 100000, 200000, 300000, 400000]
|
||||
ret.push[["${n}th is: ", nth1[select[count[1], isBlum], n]]]
|
||||
|
||||
println[formatTable[ret, "right"]]
|
||||
|
||||
d = new dict
|
||||
for n = first[select[count[1], isBlum], 400000]
|
||||
d.increment[right[toString[n],1]]
|
||||
|
||||
println["Distribution of the first 400000 Blum integers:"]
|
||||
sum = sum[d.values[]]
|
||||
for k = sort[d.keys[]]
|
||||
println[formatFix[d@k / sum, "percent", 3] + " end in $k"]
|
||||
53
Task/Blum-integer/Pluto/blum-integer.pluto
Normal file
53
Task/Blum-integer/Pluto/blum-integer.pluto
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
local int = require "int"
|
||||
local fmt = require "fmt"
|
||||
|
||||
local inc = {4, 2, 4, 2, 4, 6, 2, 6}
|
||||
|
||||
-- Assumes n is odd.
|
||||
local function first_prime_factor(n)
|
||||
if n == 1 then return 1 end
|
||||
if n % 3 == 0 then return 3 end
|
||||
if n % 5 == 0 then return 5 end
|
||||
local k = 7
|
||||
local i = 1
|
||||
while k * k <= n do
|
||||
if n % k == 0 then
|
||||
return k
|
||||
else
|
||||
k = k + inc[i]
|
||||
i = i % 8 + 1
|
||||
end
|
||||
end
|
||||
return n
|
||||
end
|
||||
|
||||
local blum = {}
|
||||
local bc = 0
|
||||
local counts = { [1] = 0, [3] = 0, [7] = 0, [9] = 0 }
|
||||
local i = 1
|
||||
while true do
|
||||
local p = first_prime_factor(i)
|
||||
if p % 4 == 3 then
|
||||
local q = i // p
|
||||
if q != p and q % 4 == 3 and int.isprime(q) then
|
||||
if bc < 50 then blum:insert(i) end
|
||||
counts[i % 10] += 1
|
||||
bc += 1
|
||||
if bc == 50 then
|
||||
print("First 50 Blum integers:")
|
||||
fmt.tprint("%3d ", blum, 10)
|
||||
print()
|
||||
elseif bc == 26828 or bc % 100_000 == 0 then
|
||||
fmt.print("The %9s Blum integer is: %9s", fmt.ord(bc, true), fmt.int(i))
|
||||
if bc == 400_000 then
|
||||
print("\n% distribution of the first 400,000 Blum integers:")
|
||||
for {1, 3, 7, 9} as j do
|
||||
fmt.print(" %6.3f%% end in %d", counts[j] / 4000, j)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
i = (i % 5 == 3) ? i + 4 : i + 2
|
||||
end
|
||||
59
Task/Blum-integer/REXX/blum-integer-1.rexx
Normal file
59
Task/Blum-integer/REXX/blum-integer-1.rexx
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
include Setting
|
||||
|
||||
Say Time()
|
||||
Call Time 'R'
|
||||
blumCount = 0
|
||||
blums.=0
|
||||
lastDigitCounts.=0
|
||||
Do number=5 By 4 While blumCount < 400000
|
||||
Prime=leastPrimeFactor(number)
|
||||
If Prime // 4=3 Then Do
|
||||
quotient=number / Prime;
|
||||
If quotient <> Prime & isPrimeType3(quotient) Then Do
|
||||
blumCount+=1
|
||||
If blumCount<=50 Then Do
|
||||
blums.blumCount=number
|
||||
End
|
||||
lastdigit=Right(number,1)
|
||||
lastDigitCounts.lastdigit+=1
|
||||
If blumCount=50 Then Do
|
||||
Say "The first 50 Blum integers:"
|
||||
Do i=1 To 50
|
||||
If Right(i,1)=1 Then
|
||||
l=Format(blums.i,3)
|
||||
Else
|
||||
l=l Format(blums.i,3)
|
||||
If i//10=0 Then
|
||||
Say l
|
||||
End
|
||||
Say ''
|
||||
End
|
||||
Else Do
|
||||
If blumCount=26828 | blumCount // 100000 = 0 Then Do
|
||||
Say "The " Format(blumCount,7)"th Blum Integer is:" Format(number,7) Time()
|
||||
If blumCount=400000 Then Do
|
||||
Say ''
|
||||
Say "Percent distribution of the first 400000 Blum integers:"
|
||||
Do i=0 To 9
|
||||
If lastDigitCounts.i>0 Then
|
||||
Say Format(lastDigitCounts.i/4000,6,3)'% end in' i
|
||||
End
|
||||
End
|
||||
End
|
||||
End
|
||||
End
|
||||
End
|
||||
End
|
||||
Say Time()
|
||||
say Time('E') 'seconds'
|
||||
Exit
|
||||
|
||||
isPrimeType3: Procedure expose Memo.
|
||||
Parse Arg number
|
||||
Return Prime(number) & (number//4=3)
|
||||
|
||||
leastPrimeFactor: Procedure expose Memo.
|
||||
Parse Arg number
|
||||
Return FFactor(number)
|
||||
|
||||
include Math
|
||||
89
Task/Blum-integer/REXX/blum-integer-2.rexx
Normal file
89
Task/Blum-integer/REXX/blum-integer-2.rexx
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
-- 28 Aug 2025
|
||||
include Setting
|
||||
arg count
|
||||
if count = '' then
|
||||
count = 400000
|
||||
threshold=25*count
|
||||
|
||||
say 'BLUM INTEGER'
|
||||
say version
|
||||
say
|
||||
say 'Parameters...'
|
||||
say 'Threshold' threshold 'Count' count
|
||||
say
|
||||
say 'Collect primes...'
|
||||
say Primes(threshold) 'found'; say
|
||||
say 'Filter primes 3 modulo 4...'
|
||||
say Filter3Mod4() 'found'; say
|
||||
say 'Generate Blum integers...'
|
||||
say GenerateBlum(threshold) 'found'; say
|
||||
say 'Blum integers...'; say
|
||||
call Results threshold,count
|
||||
call Timer
|
||||
exit
|
||||
|
||||
Filter3Mod4:
|
||||
procedure expose Prim.
|
||||
n=0
|
||||
do i = 1 to Prim.0
|
||||
if Prim.i//4 = 3 then
|
||||
n=n+1
|
||||
else
|
||||
Prim.i=0
|
||||
end
|
||||
return n
|
||||
|
||||
GenerateBlum:
|
||||
procedure expose Prim. Blum.
|
||||
arg threshold
|
||||
Blum.=0; n=0
|
||||
do i = 1 to Prim.0
|
||||
if Prim.i <> 0 then do
|
||||
do j = i+1 to Prim.0
|
||||
if Prim.j <> 0 then do
|
||||
p=Prim.i*Prim.j
|
||||
if p > threshold then
|
||||
leave j
|
||||
n=n+1; Blum.p=1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return n
|
||||
|
||||
Results:
|
||||
procedure expose Blum.
|
||||
arg threshold,count
|
||||
n=0; digs.=0
|
||||
do i = 5 by 4 to threshold
|
||||
if \ Blum.i then
|
||||
iterate i
|
||||
n=n+1
|
||||
if n > count then
|
||||
leave i
|
||||
d=Right(i,1); digs.d=digs.d+1
|
||||
if n < 51 then do
|
||||
if n = 1 then
|
||||
say 'The first 50 are'
|
||||
call CharOut ,Right(i,4)
|
||||
if n//10 = 0 then
|
||||
say
|
||||
if n = 50 then
|
||||
say
|
||||
iterate i
|
||||
end
|
||||
if n = 26828 | n//100000 = 0 then
|
||||
say 'The' n'th is' i
|
||||
if n = count then do
|
||||
say
|
||||
say 'Percent distribution of the first' count
|
||||
do i = 1 to 9
|
||||
if digs.i > 0 then
|
||||
say format(digs.i*100/count,2,3)'% ends in' i
|
||||
end
|
||||
end
|
||||
end
|
||||
say
|
||||
return 0
|
||||
|
||||
include Math
|
||||
Loading…
Add table
Add a link
Reference in a new issue