Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,61 @@
on isBrazilian(n)
repeat with b from 2 to n - 2
set d to n mod b
set temp to n div b
repeat while (temp mod b = d) -- ((temp > 0) and (temp mod b = d))
set temp to temp div b
end repeat
if (temp = 0) then return true
end repeat
return false
end isBrazilian
on isPrime(n)
if (n < 4) then return (n > 1)
if ((n mod 2 is 0) or (n mod 3 is 0)) then return false
repeat with i from 5 to (n ^ 0.5) div 1 by 6
if ((n mod i is 0) or (n mod (i + 2) is 0)) then return false
end repeat
return true
end isPrime
-- Task code:
on runTask()
set output to {}
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set collector to {}
set n to 1
repeat until ((count collector) is 20)
if (isBrazilian(n)) then set end of collector to n
set n to n + 1
end repeat
set end of output to "First 20 Brazilian numbers: " & linefeed & collector
set collector to {}
set n to 1
repeat until ((count collector) is 20)
if (isBrazilian(n)) then set end of collector to n
set n to n + 2
end repeat
set end of output to "First 20 odd Brazilian numbers: " & linefeed & collector
set collector to {}
if (isBrazilian(2)) then set end of collector to 2
set n to 3
repeat until ((count collector) is 20)
if (isPrime(n)) and (isBrazilian(n)) then set end of collector to n
set n to n + 2
end repeat
set end of output to "First 20 prime Brazilian numbers: " & linefeed & collector
set AppleScript's text item delimiters to linefeed
set output to output as text
set AppleScript's text item delimiters to astid
return output
end runTask
return runTask()

View file

@ -0,0 +1,6 @@
"First 20 Brazilian numbers:
7 8 10 12 13 14 15 16 18 20 21 22 24 26 27 28 30 31 32 33
First 20 odd Brazilian numbers:
7 13 15 21 27 31 33 35 39 43 45 51 55 57 63 65 69 73 75 77
First 20 prime Brazilian numbers:
7 13 31 43 73 127 157 211 241 307 421 463 601 757 1093 1123 1483 1723 2551 2801"