Skip to content
Snippets Groups Projects
Commit b21b50eb authored by nimrod's avatar nimrod
Browse files

Added AWK version.

parent 146b167d
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/awk -f
function isPrime (x) {
if (sqrt(x) % 1 == 0)
return 0
for (j = 2; j < sqrt(x); j++)
if (x % j == 0)
return 0
return 1
}
BEGIN {
n = 0
for (i = 0; n < ARGV[1]; i++)
if (isPrime(i)) {
arr[n] = i
n++
}
for (i in arr)
print arr[i]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment