Skip to content

Commit

Permalink
feat(6-numeros-primos): a bit more optimized version (i think)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantotone committed Oct 6, 2023
1 parent 9b1223c commit 36e8ed9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions challenges/6-numeros-primos/crystal/pantotone/main-v2.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
number : Int32 = ARGV[0].to_i

def isPrime(number : Int32)
return false if number < 2
return true if number == 2

divisor : Int32 = 1
unless divisor > Math.isqrt(number)
divisor += 1
return false if number % divisor == 0
end

return true
end

puts isPrime(number)

0 comments on commit 36e8ed9

Please sign in to comment.