Count Divisors
EasyPractice library · +10 XPbasicsloopsarithmetic
Given a positive integer N, find the number of positive integers less than or equal to N that are divisors of N. A divisor of N is a number that divides N evenly, leaving no remainder.
Input
A single line containing a positive integer N.
Output
A single integer representing the count of divisors of N.
Constraints
1 <= N <= 1000
Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests
Example 1
Input
12
Output
6
The divisors of 12 are 1, 2, 3, 4, 6, and 12. There are 6 divisors.
Example 2
Input
7
Output
2
The divisors of 7 are 1 and 7. There are 2 divisors.
Hints
# Read the input from stdin and print the answer.
import sys
def main():
data = sys.stdin.read().split()
# your code here
main()
Example 1 input
12
Example 2 input
7