Calculating Odd/Even number of divisors in Python
The challenge
Given an integer n
return "odd"
if the number of its divisors is odd. Otherwise, return "even"
.
Note: big inputs will be tested.
Examples:
All prime numbers have exactly two divisors (hence "even"
).
For n = 12
the divisors are [1, 2, 3, 4, 6, 12]
– "even"
.
For n = 4
the divisors are [1, 2, 4]
– "odd"
.
The solution in Python code
Option 1:
Option 2:
Option 3:
|
|