Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,41 @@
include "NSLog.incl"
local fn Factorial( n as NSUInteger ) as NSUInteger
NSUInteger factorial = 1
if n > 1 then factorial = n * fn Factorial( n -1 )
end fn = factorial
local fn IsPrime( n as NSUInteger ) as BOOL
BOOL isPrime = YES
NSUInteger i
if n < 2 then exit fn = NO
if n = 2 then exit fn = YES
if n mod 2 == 0 then exit fn = NO
for i = 3 to int(n^.5) step 2
if n mod i == 0 then exit fn = NO
next
end fn = isPrime
void local fn FactorialPrimes( n as long )
NSUInteger found = 0, i = 1
NSLog( @"First %lu factorial primes:", n )
while ( found < n )
NSUInteger fct = fn Factorial( i )
if ( fn IsPrime( fct - 1 ) )
found++
NSLog( @"%2lu: %3lu! - 1 = %-lu", found, i, fct - 1 )
end if
if ( fn IsPrime( fct + 1 ) )
found++
NSLog( @"%2lu: %3lu! + 1 = %-lu", found, i, fct + 1 )
end if
i++
wend
end fn
fn FactorialPrimes( 10 )
HandleEvents