mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-10-29 22:17:23 +01:00
✨ Add "is-prime-number" challenge
This commit is contained in:
parent
888940a04c
commit
6a40154d93
13
challenges/is-prime-number/README.md
Normal file
13
challenges/is-prime-number/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# is-prime-number
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) at 5 July 2020.
|
||||
|
||||
## Instructions :
|
||||
|
||||
The function should return `true` if a given number is a prime number and `false` otherwise.
|
||||
|
||||
**Note :** A prime number is a natural integer which admits exactly two distinct positive divisors. (1 and itself). Example: 2, 3, 5, 7, 11, 13, 17, 19 ...
|
||||
|
||||
## Examples :
|
||||
|
||||
See the `input-output.json` file for examples of input/output.
|
18
challenges/is-prime-number/input-output.json
Normal file
18
challenges/is-prime-number/input-output.json
Normal file
@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"input": [4],
|
||||
"output": false
|
||||
},
|
||||
{
|
||||
"input": [19],
|
||||
"output": true
|
||||
},
|
||||
{
|
||||
"input": [97],
|
||||
"output": true
|
||||
},
|
||||
{
|
||||
"input": [54],
|
||||
"output": false
|
||||
}
|
||||
]
|
0
challenges/is-prime-number/solutions/.gitkeep
Normal file
0
challenges/is-prime-number/solutions/.gitkeep
Normal file
@ -0,0 +1,4 @@
|
||||
# python-prime - is-prime-number
|
||||
|
||||
Programming language : Python
|
||||
Created by [@Divlo](https://github.com/Divlo) at 5 July 2020.
|
@ -0,0 +1,10 @@
|
||||
# Only the non-zero and positive divisors
|
||||
def divider_list(number):
|
||||
number_list = []
|
||||
for index in range(1, number + 1):
|
||||
if number % index == 0:
|
||||
number_list.append(index)
|
||||
return number_list
|
||||
|
||||
def solution(number):
|
||||
return len(divider_list(number)) == 2
|
Loading…
Reference in New Issue
Block a user