The Divisor Count
EasyAcc. 97.4%
+15 XP 5
Examining Factors
Every number has at least two divisors (1 and itself). Counting them all helps us identify prime or composite numbers.
The Assignment
Your function receives a parameter named target.
- Initialize
countto 0. - Loop from 1 to
target. - If
targetis divisible by the current loop index, incrementcount. - After the loop, print the final
count.
01EXAMPLE 1
Input
target = 6Output
4Explanation: Divisors: 1, 2, 3, 6.
Constraints
- Use a standard for loop.
- Check all numbers between 1 and target.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
target6
Expected Output
4
Click RUN to test your solution