Data update

This commit is contained in:
Ingy döt Net 2023-12-16 21:33:55 -08:00
parent 35bcdeebf8
commit 74c69a0df6
2427 changed files with 31826 additions and 3468 deletions

View file

@ -5,11 +5,11 @@
using big_int = mpz_class;
std::string to_string(const big_int& num, size_t n) {
std::string to_string(const big_int& num, size_t max_digits) {
std::string str = num.get_str();
size_t len = str.size();
if (len > n) {
str = str.substr(0, n / 2) + "..." + str.substr(len - n / 2);
if (len > max_digits) {
str.replace(max_digits / 2, len - max_digits, "...");
str += " (";
str += std::to_string(len);
str += " digits)";

View file

@ -0,0 +1,26 @@
func isprim num .
if num < 2
return 0
.
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
f = 1
while count < 10
n += 1
f *= n
op$ = "-"
for fp in [ f - 1 f + 1 ]
if isprim fp = 1
count += 1
print n & "! " & op$ & " 1 = " & fp
.
op$ = "+"
.
.

View file

@ -10,7 +10,7 @@ do -- find some factorial primes - primes that are f - 1 or f + 1
local rootP = math.floor( math.sqrt( p ) )
while i <= rootP and prime do
prime = p % i ~= 0
i = i + 1
i = i + 2
end
return prime
end

View file

@ -0,0 +1,24 @@
;XIncludeFile "isprime.pb"
;XIncludeFile "factorial.pb"
If OpenConsole()
PrintN("First 10 factorial primes:")
Define found.i = 0, i,i = 1, fct.i
While found < 10
fct = factorial (i)
If isprime(fct-1)
found + 1
PrintN(RSet(Str(found),2) + ": " + RSet(Str(i),2) + "! - 1 = " + Str(fct-1))
EndIf
If isprime(fct+1)
found + 1
PrintN(RSet(Str(found),2) + ": " + RSet(Str(i),2) + "! + 1 = " + Str(fct+1))
EndIf
i + 1
Wend
PrintN(#CRLF$ + "--- terminado, pulsa RETURN---"): Input()
CloseConsole()
EndIf