Data update

This commit is contained in:
Ingy döt Net 2024-03-06 22:25:12 -08:00
parent ed705008a8
commit 0df55f9f24
2196 changed files with 32999 additions and 3075 deletions

View file

@ -0,0 +1,76 @@
Dim Shared Factors(3) As Uinteger
Function Sphenic(N As Uinteger) As Boolean
Dim As Uinteger C, F, L, Q
L = Sqr(N)
C = 0
F = 2
Do
Q = N / F
If N Mod F = 0 Then
Factors(C) = F
C += 1
If C > 3 Then Return False
N = Q
If N Mod F = 0 Then Return False
If F > N Then Exit Do
Else
F += 1
If F > L Then
Factors(C) = N
C += 1
Exit Do
End If
End If
Loop
Return Iif(C = 3, True, False)
End Function
Dim As Double t0 = Timer
Dim As Uinteger C, N, I
C = 0
N = 2 * 3 * 5
Print "Sphenic numbers less than 1,000:"
Do
If Sphenic(N) Then
C += 1
If N < 1000 Then
Print Using "####"; N;
If C Mod 15 = 0 Then Print
End If
If C = 200000 Then
Print "The 200,000th sphenic number is "; N; " = ";
For I = 0 To 2
Print Factors(I);
If I < 2 Then Print " * ";
Next I
Print
End If
End If
N += 1
If N >= 1e6 Then Exit Do
Loop
Print "There are "; C; " sphenic numbers less than 1,000,000"
C = 0
N = 2 * 3 * 5
Print !"\nSphenic triplets less than 10,000:"
Do
If Sphenic(N) Andalso Sphenic(N+1) Andalso Sphenic(N+2) Then
C += 1
If N < 10000 Then
Print "[" & N & ", " & N+1 & ", " & N+2 & "]";
If C Mod 3 = 0 Then Print Else Print ", ";
End If
If C = 5000 Then
Print "The 5000th sphenic triplet is [" & N & ", " & N+1 & ", " & N+2 & "]"
End If
End If
N += 1
If N+2 >= 1e6 Then Exit Do
Loop
Print "There are "; C; " sphenic triplets less than 1,000,000"
Print Using "##.##sec."; Timer - t0
Sleep

View file

@ -0,0 +1,81 @@
Global Dim Factors(3)
Procedure.i Sphenic(N)
Protected C, F, L, Q, res
L = Sqr(N)
C = 0
F = 2
While 1
Q = N / F
If N % F = 0
Factors(C) = F
C + 1
If C > 3 : ProcedureReturn #False : EndIf
N = Q
If N % F = 0 : ProcedureReturn #False : EndIf
If F > N : Break : EndIf
Else
F + 1
If F > L
Factors(C) = N
C + 1
Break
EndIf
EndIf
Wend
If C = 3
res = #True
Else
res = #False
EndIf
ProcedureReturn res
EndProcedure
OpenConsole()
t0 = ElapsedMilliseconds()
C = 0
N = 2 * 3 * 5
PrintN("Sphenic numbers less than 1,000:")
While 1
If Sphenic(N)
C + 1
If N < 1000
Print(Str(N) + " ")
If C % 15 = 0 : PrintN("") : EndIf
EndIf
If C = 200000
Print("The 200,000th sphenic number is " + Str(N) + " = ")
For I = 0 To 2
Print(Str(Factors(I)))
If I < 2 : Print(" * ") : EndIf
Next I
PrintN("")
EndIf
EndIf
N + 1
If N >= 1e6 : Break : EndIf
Wend
PrintN("There are " + Str(C) + " sphenic numbers less than 1,000,000")
C = 0
N = 2 * 3 * 5
PrintN(#CRLF$ + "Sphenic triplets less than 10,000:")
While 1
If Sphenic(N) And Sphenic(N+1) And Sphenic(N+2)
C + 1
If N < 10000
Print("[" + Str(N) + ", " + Str(N+1) + ", " + Str(N+2) + "]")
If C % 3 = 0 : PrintN("") : Else : Print(", ") : EndIf
EndIf
If C = 5000
PrintN("The 5000th sphenic triplet is [" + Str(N) + ", " + Str(N+1) + ", " + Str(N+2) + "]")
EndIf
EndIf
N + 1
If N+2 >= 1e6 : Break : EndIf
Wend
PrintN("There are " + Str(C) + " sphenic triplets less than 1,000,000")
PrintN(StrF((ElapsedMilliseconds() - t0) / 1000, 2) + "sec.")
PrintN(#CRLF$ + "Press ENTER to exit"): Input()
CloseConsole()

View file

@ -0,0 +1,69 @@
dim Factors(3)
C = 0
N = 2 * 3 * 5
print "Sphenic numbers less than 1,000:"
do
if Sphenic(N) then
C = C + 1
if N < 1000 then
print N using "####";
if mod(C, 15) = 0 print
fi
if C = 2e5 then
print "The 200,000th sphenic number is ", N, " = ";
for I = 0 to 2
print Factors(I);
if I < 2 print " * ";
next I
print
fi
fi
N = N + 1
if N >= 1e6 break
loop
print "There are ", C, " sphenic numbers less than 1,000,000"
C = 0
N = 2 * 3 * 5
print "\nSphenic triplets less than 10,000:"
do
if Sphenic(N) and Sphenic(N+1) and Sphenic(N+2) then
C = C + 1
if N < 10000 then
print "[", N, ", ", N+1, ", ", N+2, "]";
if mod(C, 3) = 0 then print else print ", "; : fi
fi
if C = 5000 print "The 5000th sphenic triplet is [", N, ", ", N+1, ", ", N+2, "]"
fi
N = N + 1
if N+2 >= 1e6 break
loop
print "There are ", C, " sphenic triplets less than 1,000,000"
print peek("millisrunning") / 1000, "sec."
end
sub Sphenic(N)
local C, F, L, Q
L = sqr(N)
C = 0
F = 2
do
Q = N / F
if mod(N, F) = 0 then
Factors(C) = F
C = C + 1
if C > 3 return false
N = Q
if mod(N, F) = 0 return false
if F > N break
else
F = F + 1
if F > L then
Factors(C) = N
C = C + 1
break
fi
fi
loop
return (C = 3)
end sub