Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,64 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Factorions is
|
||||
subtype Factorial_Domain is Natural range 0 .. 11;
|
||||
subtype Log_Base is Positive range 2 .. Positive'Last;
|
||||
type Result_Table is array (Factorial_Domain) of Positive;
|
||||
|
||||
Factorial : Result_Table;
|
||||
Search_Limit : Positive := 1_500_000;
|
||||
|
||||
procedure Precompute_Factorials is
|
||||
begin
|
||||
Factorial (0) := 1;
|
||||
|
||||
for I in 1 .. Factorial'Last loop
|
||||
Factorial (I) := I * Factorial (I - 1);
|
||||
end loop;
|
||||
end Precompute_Factorials;
|
||||
|
||||
function Floor_Log (Number : Positive; Base : Log_Base) return Natural is
|
||||
Remaining : Natural := Number;
|
||||
Floor_Log : Natural := 0;
|
||||
begin
|
||||
while Remaining > Base loop
|
||||
Remaining := Remaining / Base;
|
||||
Floor_Log := Floor_Log + 1;
|
||||
end loop;
|
||||
|
||||
return Floor_Log;
|
||||
end Floor_Log;
|
||||
|
||||
function Digit (Number, Index : Natural; Base : Log_Base) return Natural is
|
||||
begin
|
||||
return (Number / (Base ** Index)) mod Base;
|
||||
end Digit;
|
||||
|
||||
function Is_Factorion (Number : Positive; Base : Log_Base) return Boolean is
|
||||
Digit_Sum : Natural := 0;
|
||||
begin
|
||||
for I in 0 .. Floor_Log (Number, Base) loop
|
||||
Digit_Sum := Digit_Sum + Factorial (Digit (Number, I, Base));
|
||||
end loop;
|
||||
|
||||
return Digit_Sum = Number;
|
||||
end Is_Factorion;
|
||||
|
||||
procedure Show_Factorions (Base : Log_Base) is
|
||||
begin
|
||||
Ada.Text_IO.Put_Line ("Search Base " & Base'Image);
|
||||
for I in 1 .. Search_Limit loop
|
||||
if Is_Factorion (I, Base) then
|
||||
Ada.Text_IO.Put_Line (I'Image);
|
||||
end if;
|
||||
end loop;
|
||||
Ada.Text_IO.Put_Line ("Done Base " & Base'Image);
|
||||
end Show_Factorions;
|
||||
|
||||
begin
|
||||
Precompute_Factorials;
|
||||
Show_Factorions (9);
|
||||
Show_Factorions (10);
|
||||
Show_Factorions (11);
|
||||
Show_Factorions (12);
|
||||
end Factorions;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
factorials: [1 1 2 6 24 120 720 5040 40320 362880 3628800 39916800]
|
||||
|
||||
factorion?: function [n, base][
|
||||
try? [
|
||||
if throws? [
|
||||
n = sum map digits.base:base n 'x -> factorials\[x]
|
||||
]
|
||||
else [
|
||||
][
|
||||
print ["n:" n "base:" base]
|
||||
false
|
||||
]
|
||||
|
|
@ -12,4 +11,3 @@ factorion?: function [n, base][
|
|||
|
||||
loop 9..12 'base ->
|
||||
print ["Base" base "factorions:" select 1..45000 'z -> factorion? z base]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
fact_digsum <- function(n, b){
|
||||
if(n>b-1){
|
||||
return(factorial(n%%b)+fact_digsum(n%/%b, b))
|
||||
}
|
||||
else return(factorial(n))
|
||||
factorial(n%%b)+fact_digsum(n%/%b, b)
|
||||
} else factorial(n)
|
||||
}
|
||||
|
||||
for(i in 9:12){
|
||||
cat("Factorions in base",i,"\n")
|
||||
cat("\nFactorions in base ", i, ":\n", sep="")
|
||||
for(j in 1:1499999){
|
||||
if(j==fact_digsum(j, i)) print(j)
|
||||
if(j==fact_digsum(j, i)) cat(j, "")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
' Factorions - VBScript - PG - 26/04/2020
|
||||
Dim fact()
|
||||
nn1=9 : nn2=12
|
||||
lim=1499999
|
||||
ReDim fact(nn2)
|
||||
fact(0)=1
|
||||
For i=1 To nn2
|
||||
fact(i)=fact(i-1)*i
|
||||
Next
|
||||
For base=nn1 To nn2
|
||||
list=""
|
||||
For i=1 To lim
|
||||
s=0
|
||||
t=i
|
||||
Do While t<>0
|
||||
d=t Mod base
|
||||
s=s+fact(d)
|
||||
t=t\base
|
||||
Loop
|
||||
If s=i Then list=list &" "& i
|
||||
Next
|
||||
Wscript.Echo "the factorions for base "& right(" "& base,2) &" are: "& list
|
||||
Next
|
||||
Loading…
Add table
Add a link
Reference in a new issue