Solved Problem - Factorization
In the lesson, we look at an efficient way to factor a number.
We'll cover the following
Problem statement
Given a number , count the number of factors of the number N.
Input format
A single line of input contains the number .
Output format
Print a single integer equal to the number of factors of .
Sample
Input
36
Output
9
Explanation
Factors of
Count:
Brute force
The brute force solution would be to loop over all the numbers from 1
to N
and check if it is a factor. If it is, you would then print it.
We can use the modulus operator to check if it’s a factor or not.
Here is the code:
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy