summaryrefslogtreecommitdiffstats
path: root/7.lua
diff options
context:
space:
mode:
Diffstat (limited to '7.lua')
-rw-r--r--7.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/7.lua b/7.lua
new file mode 100644
index 0000000..d5af641
--- /dev/null
+++ b/7.lua
@@ -0,0 +1,19 @@
+function isprime(n)
+ if n < 2 then return false end
+ if n == 2 then return true end
+ if math.fmod(n, 2) == 0 then return false end
+ for i = 3, math.ceil(math.sqrt(n)), 2 do
+ if math.fmod(n, i) == 0 then return false end
+ end
+ return true
+end
+
+local i = 2
+local primes = 0
+while true do
+ if isprime(i) then
+ primes = primes + 1
+ if primes == 10001 then print(i); break end
+ end
+ i = i + 1
+end