Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,4 +1,4 @@
BEGIN # find some abundant odd numbers - numbers wose the proper divisor sum #
BEGIN # find some abundant odd numbers - numbers where the proper divisor sum #
# is bigger than the number itself #
# returns the sum of the proper divisors of n #

View file

@ -1,57 +0,0 @@
with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N) > N);
package NIO is new Ada.Text_IO.Integer_IO(Natural);
Current: Positive := 1;
procedure Print_Abundant_Line
(Idx: Positive; N: Positive; With_Idx: Boolean:= True) is
begin
if With_Idx then
NIO.Put(Idx, 6); Ada.Text_IO.Put(" |");
else
Ada.Text_IO.Put(" *** |");
end if;
NIO.Put(N, 12); Ada.Text_IO.Put(" | ");
NIO.Put(Divisor_Sum.Process(N), 12); Ada.Text_IO.New_Line;
end Print_Abundant_Line;
begin
-- the first 25 abundant odd numbers
Ada.Text_IO.Put_Line(" index | number | proper divisor sum ");
Ada.Text_IO.Put_Line("-------+-------------+--------------------");
for I in 1 .. 25 loop
while not Abundant(Current) loop
Current := Current + 2;
end loop;
Print_Abundant_Line(I, Current);
Current := Current + 2;
end loop;
-- the one thousandth abundant odd number
Ada.Text_IO.Put_Line("-------+-------------+--------------------");
for I in 26 .. 1_000 loop
Current := Current + 2;
while not Abundant(Current) loop
Current := Current + 2;
end loop;
end loop;
Print_Abundant_Line(1000, Current);
-- the first abundant odd number greater than 10**9
Ada.Text_IO.Put_Line("-------+-------------+--------------------");
Current := 10**9+1;
while not Abundant(Current) loop
Current := Current + 2;
end loop;
Print_Abundant_Line(1, Current, False);
end Odd_Abundant;

View file

@ -35,7 +35,7 @@ scope # find some abundant snumbers
fi;
odd_number +:= 2
od;
printf( "1000th abundant odd number:\n %d proper divisor sum: %d\n", odd_number, d_sum );
printf( "1000th abundant odd number:\n %d proper divisor sum: %d\n", odd_number - 2, d_sum );
# first odd abundant number > one billion
odd_number := 1_000_000_001;
local found := false;
@ -43,7 +43,7 @@ scope # find some abundant snumbers
d_sum := divisor_sum( odd_number );
if d_sum > odd_number then
found := true;
print( "First abundant odd_number > 1 000 000 000:" );
print( "First abundant odd number > 1 000 000 000:" );
printf( " %d proper divisor sum: %d\n", odd_number, d_sum );
fi;
odd_number +:= 2

View file

@ -1,7 +1,7 @@
abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
[i, found]: [1, 0]
while [found<25][
if abundant? i [
inc 'found
@ -10,7 +10,7 @@ while [found<25][
'i + 2
]
[i, found]: @[new 1, new 0]
[i, found]: [1, 0]
while [found<1000][
if abundant? i [
inc 'found
@ -19,7 +19,7 @@ while [found<1000][
]
print ["the 1000th abundant odd number:" i-2 "=> sum:" sum factors i-2]
i: new 1 + 10^9
i: 1 + 10^9
while ø [
if abundant? i [
print ["the first abundant odd number greater than one billion (10^9):" i "=> sum:" sum factors i]

View file

@ -1,20 +1,20 @@
Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor(n/i)] := true
Loop % n/x
if !Mod(n, i:=A_Index+1) && (i < n)
Array[i] := true
return Array
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor(n/i)] := true
Loop % n/x
if !Mod(n, i:=A_Index+1) && (i < n)
Array[i] := true
return Array
}

View file

@ -1,25 +1,25 @@
output := "First 25 abundant odd numbers:`n"
while (count<1000)
{
oddNum := 2*A_Index-1
if (str := Abundant(oddNum))
{
count++
if (count<=25)
output .= oddNum " " str "`n"
if (count = 1000)
output .= "`nOne thousandth abundant odd number:`n" oddNum " " str "`n"
}
oddNum := 2*A_Index-1
if (str := Abundant(oddNum))
{
count++
if (count<=25)
output .= oddNum " " str "`n"
if (count = 1000)
output .= "`nOne thousandth abundant odd number:`n" oddNum " " str "`n"
}
}
count := 0
while !count
{
num := 2*A_Index -1 + 1000000000
if (str := Abundant(num))
{
count++
output .= "`nFirst abundant odd number greater than one billion:`n" num " " str "`n"
}
num := 2*A_Index -1 + 1000000000
if (str := Abundant(num))
{
count++
output .= "`nFirst abundant odd number greater than one billion:`n" num " " str "`n"
}
}
MsgBox % output
return

View file

@ -3,37 +3,37 @@ contar = 0
sumaDiv = 0
function SumaDivisores(n)
# Devuelve la suma de los divisores propios de n
suma = 1
i = int(sqr(n))
# Devuelve la suma de los divisores propios de n
suma = 1
i = int(sqr(n))
for d = 2 to i
if n % d = 0 then
suma += d
otroD = n \ d
if otroD <> d Then suma += otroD
end if
Next d
Return suma
for d = 2 to i
if n % d = 0 then
suma += d
otroD = n \ d
if otroD <> d Then suma += otroD
end if
Next d
Return suma
End Function
# Encontrar los números requeridos por la tarea:
# primeros 25 números abundantes impares
Print "Los primeros 25 números impares abundantes:"
While contar < 25
sumaDiv = SumaDivisores(numimpar)
If sumaDiv > numimpar Then
contar += 1
Print numimpar & " suma divisoria adecuada: " & sumaDiv
End If
numimpar += 2
sumaDiv = SumaDivisores(numimpar)
If sumaDiv > numimpar Then
contar += 1
Print numimpar & " suma divisoria adecuada: " & sumaDiv
End If
numimpar += 2
End While
# 1000er número impar abundante
While contar < 1000
sumaDiv = SumaDivisores(numimpar)
If sumaDiv > numimpar Then contar += 1
numimpar += 2
sumaDiv = SumaDivisores(numimpar)
If sumaDiv > numimpar Then contar += 1
numimpar += 2
End While
Print Chr(10) & "1000º número impar abundante:"
Print " " & (numimpar - 2) & " suma divisoria adecuada: " & sumaDiv
@ -42,12 +42,12 @@ Print " " & (numimpar - 2) & " suma divisoria adecuada: " & sumaDiv
numimpar = 1000000001
encontrado = False
While Not encontrado
sumaDiv = SumaDivisores(numimpar)
If sumaDiv > numimpar Then
encontrado = True
Print Chr(10) & "Primer número impar abundante > 1 000 000 000:"
Print " " & numimpar & " suma divisoria adecuada: " & sumaDiv
End If
numimpar += 2
sumaDiv = SumaDivisores(numimpar)
If sumaDiv > numimpar Then
encontrado = True
Print Chr(10) & "Primer número impar abundante > 1 000 000 000:"
Print " " & numimpar & " suma divisoria adecuada: " & sumaDiv
End If
numimpar += 2
End While
End

View file

@ -1,44 +1,44 @@
divisorSum = function(n)
ans = 0
i = 1
while i * i <= n
if n % i == 0 then
ans += i
j = floor(n / i)
if j != i then ans += j
end if
i += 1
end while
return ans
ans = 0
i = 1
while i * i <= n
if n % i == 0 then
ans += i
j = floor(n / i)
if j != i then ans += j
end if
i += 1
end while
return ans
end function
cnt = 0
n = 1
while cnt < 25
sum = divisorSum(n) - n
if sum > n then
print n + ": " + sum
cnt += 1
end if
n += 2
sum = divisorSum(n) - n
if sum > n then
print n + ": " + sum
cnt += 1
end if
n += 2
end while
while true
sum = divisorSum(n) - n
if sum > n then
cnt += 1
if cnt == 1000 then break
end if
n += 2
sum = divisorSum(n) - n
if sum > n then
cnt += 1
if cnt == 1000 then break
end if
n += 2
end while
print "The 1000th abundant number is " + n + " with a proper divisor sum of " + sum
n = 1000000001
while true
sum = divisorSum(n) - n
if sum > n and n > 1000000000 then break
n += 2
sum = divisorSum(n) - n
if sum > n and n > 1000000000 then break
n += 2
end while
print "The first abundant number > 1b is " + n + " with a proper divisor sum of " + sum

View file

@ -1,23 +1,22 @@
(phixonline)-->
<span style="color: #008080;">function</span> <span style="color: #000000;">abundantOdd</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">done</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">lim</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">bool</span> <span style="color: #000000;">printAll</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">done</span><span style="color: #0000FF;"><</span><span style="color: #000000;">lim</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">tot</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sum</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">factors</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">1</span><span style="color: #0000FF;">))</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">tot</span><span style="color: #0000FF;">></span><span style="color: #000000;">n</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">done</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">printAll</span> <span style="color: #008080;">or</span> <span style="color: #000000;">done</span><span style="color: #0000FF;">=</span><span style="color: #000000;">lim</span> <span style="color: #008080;">then</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">ln</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">printAll</span><span style="color: #0000FF;">?</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%2d. "</span><span style="color: #0000FF;">,</span><span style="color: #000000;">done</span><span style="color: #0000FF;">):</span><span style="color: #008000;">""</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s%,6d (proper sum:%,d)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">ln</span><span style="color: #0000FF;">,</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span><span style="color: #000000;">tot</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #000000;">n</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">2</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">n</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The first 25 abundant odd numbers are:\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">n</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">abundantOdd</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">25</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">true</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The one thousandth abundant odd number is:"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">abundantOdd</span><span style="color: #0000FF;">(</span><span style="color: #000000;">n</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">25</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1000</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">false</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"The first abundant odd number above one billion is:"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">abundantOdd</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1e9</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">false</span><span style="color: #0000FF;">)</span>
<!--
with javascript_semantics
function abundantOdd(integer n, done, lim, bool printAll)
while done<lim do
atom tot = sum(factors(n,-1))
if tot>n then
done += 1
if printAll or done=lim then
string ln = iff(printAll?sprintf("%2d. ",done):"")
printf(1,"%s%,6d (proper sum:%,d)\n",{ln,n,tot})
end if
end if
n += 2
end while
printf(1,"\n")
return n
end function
printf(1,"The first 25 abundant odd numbers are:\n")
integer n = abundantOdd(1, 0, 25, true)
printf(1,"The one thousandth abundant odd number is:")
{} = abundantOdd(n, 25, 1000, false)
printf(1,"The first abundant odd number above one billion is:")
{} = abundantOdd(1e9+1, 0, 1, false)

View file

@ -2,13 +2,13 @@ fcn oddAbundants(startAt=3){ //--> iterator
Walker.zero().tweak(fcn(rn){
n:=rn.value;
while(True){
sum:=0;
foreach d in ([3.. n.toFloat().sqrt().toInt(), 2]){
if( (y:=n/d) *d != n) continue;
sum += ((y==d) and y or y+d)
}
if(sum>n){ rn.set(n+2); return(n) }
n+=2;
sum:=0;
foreach d in ([3.. n.toFloat().sqrt().toInt(), 2]){
if( (y:=n/d) *d != n) continue;
sum += ((y==d) and y or y+d)
}
if(sum>n){ rn.set(n+2); return(n) }
n+=2;
}
}.fp(Ref(startAt.isOdd and startAt or startAt+1)))
}