local int = require "int" local fmt = require "fmt" local a1, a2 = {}, {} local n = 0 local r1, r2, r3 local p = 1 local c = 0 while true do p = int.nextprime(p) c += 1 if c <= 20 then a1:insert(p) end if 100 < p < 150 then a2:insert(p) end if 7700 < p < 8000 then n += 1 end if c == 10_000 then r1 = p end if c == 100_000 then r2 = p end if c == 1_000_000 then r3 = p break end end print("The first 20 primes are: ") fmt.lprint(a1) print("\nThe primes between 100 and 150 are: ") fmt.lprint(a2) print($"\nThe number of primes between 7,700 and 8,000 is {n}.") fmt.print("\nThe 10,000th prime is %,s.", r1) fmt.print("\nThe 100,000th prime is %,s.", r2) fmt.print("\nThe 1,000,000th prime is %,s.", r3)