RosettaCodeData/Task/Loops-Increment-loop-index-within-loop-body/Julia/loops-increment-loop-index-within-loop-body.jl
2024-10-16 18:07:41 -07:00

17 lines
384 B
Julia

using Primes, Formatting
function doublemyindex(n=42)
shown = 0
i = BigInt(n)
while shown < n
if isprime(i + 1)
shown += 1
println("The index is ", format(shown, commas=true), " and ",
format(i + 1, commas=true), " is prime.")
i += i
end
i += 1
end
end
doublemyindex()