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.

  1. Initialize count to 0.
  2. Loop from 1 to target.
  3. If target is divisible by the current loop index, increment count.
  4. After the loop, print the final count.

01EXAMPLE 1

Inputtarget = 6
Output4

Explanation: Divisors: 1, 2, 3, 6.

Constraints

  • Use a standard for loop.
  • Check all numbers between 1 and target.
MathLoops
JavaScript
Loading...
3 Hidden

Input Arguments

target6

Expected Output

4

Click RUN to test your solution