Skip to content

Instantly share code, notes, and snippets.

@dyjjones
Created August 9, 2014 23:04
Show Gist options
  • Save dyjjones/6f9e3219e603e8958644 to your computer and use it in GitHub Desktop.
Save dyjjones/6f9e3219e603e8958644 to your computer and use it in GitHub Desktop.
function is_prime(n)
if n < 4
return true
end
if n % 2 == 0
return false
end
for a = 3:int(sqrt(n))
if n % a == 0
return false
end
end
return true
end
function calculate_primes(n)
primes = Int64[]
p = 1
for i = 1:n
while ! is_prime(p)
p += 1
end
push!(primes, p)
p += 1
end
return primes
end
calculate_primes(int(ARGS[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment