Company: Infosys
Difficulty: medium
Steps to Zero You are given an integer N. In one step, you can do one of the following operations: If N is divisible by 5 then divide it by 5. If N is not divisible by 5 but divisible by 3 then divide it by 3. If N is not divisible by 5 and 3 but divisible by 2 then divide it by 2. If N is not divisible by 5, 3, and 2 then subtract 1 from N. Your task is to find the number of steps needed to make N zero. Function Description Complete the countSteps function with the following parameter(s): Name Type Description N INTEGER The given integer. Return: The function must return an INTEGER denoting the number of steps needed to make N zero. Constraints 1 ≤ N ≤ 10 6 Sample Test Cases Input: 6 Output: 3 Step-1: 6 is not divisible by 5 but divisible by 3 hence divide it by 3 so N=2 Step-2: 2 is not divisible by 5 and 3 but divisible by 2 hence divide it by 2 so N=1 Step-3: 1 is not divisible by 5,3 and 2 hence subtract 1 so N=0 Hence here steps needed is 3 so the answer is 3. Input: 12 Output: 4