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,44 @@
import "./math" for Int, Nums
import "./fmt" for Fmt
var limit = 1e8
var primes = Int.primeSieve(7 * limit)
var under250 = List.filled(250, 0)
var sisyphus = [1]
under250[1] = 1
var prev = 1
var nextPrimeIndex = 0
var specific = 1000
var count = 1
while (true) {
var next
if (prev % 2 == 0) {
next = prev / 2
} else {
next = prev + primes[nextPrimeIndex]
nextPrimeIndex = nextPrimeIndex + 1
}
count = count + 1
if (count <= 100) sisyphus.add(next)
if (next < 250) under250[next] = under250[next] + 1
if (count == 100) {
System.print("The first 100 members of the Sisyphus sequence are:")
Fmt.tprint("$3d ", sisyphus, 10)
System.print()
} else if (count == specific) {
var prime = primes[nextPrimeIndex-1]
Fmt.print("$,13r member is: $,13d and highest prime needed: $,11d", count, next, prime)
if (count == limit) {
var notFound = (1..249).where { |i| under250[i] == 0 }.toList
var max = Nums.max(under250)
var maxFound = (1..249).where { |i| under250[i] == max }.toList
Fmt.print("\nThese numbers under 250 do not occur in the first $,d terms:", count)
Fmt.print(" $n", notFound)
Fmt.print("\nThese numbers under 250 occur the most in the first $,d terms:", count)
Fmt.print(" $n all occur $d times.", maxFound, max)
return
}
specific = 10 * specific
}
prev = next
}

View file

@ -0,0 +1,21 @@
import "./psieve" for Primes
import "./fmt" for Fmt
var it = Primes.iter()
var n = 1
var count = 1
var prime
var target = 36
while (true) {
if (n % 2 == 1) {
prime = it.next
n = n + prime
} else {
n = n / 2
}
count = count + 1
if (n == target) {
Fmt.print("$,r member is: $d and highest prime needed: $,d", count, target, prime)
return
}
}