Skip to content

Commit

Permalink
feat(6-numeros-primos): baby first prime number checker
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantotone committed Oct 6, 2023
1 parent 9b131a5 commit 9b1223c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions challenges/6-numeros-primos/crystal/pantotone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Submissão de Exercicio

**Exercicio:** 6 - Números Primos

**Nickname:** Pantotone

**Nível Técnico:** Estudante

**Empresa:** Freelancer

**Twitter**: https://twitter.com/pantotone

**Dificuldade de Resolução:** - Média

**Comentários:** Mexendo com código faz anos, e nunca fiz um checker pra números primos..

**Como rodar o desafio**:

Use o comando abaixo:
```bash
crystal main.cr <input>
```
13 changes: 13 additions & 0 deletions challenges/6-numeros-primos/crystal/pantotone/main.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
number : Int32 = ARGV[0].to_i

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

divisors = (2..number).select do |divisor|
number % divisor == 0
end

return divisors.size == 1
end

puts isPrime(number)

0 comments on commit 9b1223c

Please sign in to comment.