Withdrawing Money
Submissions: 1347   Accuracy:

11.36%

  Difficulty: Easy   Marks: 2

Ishaan has N dollars in his bank account. He wants to withdraw all of it. But the bank has a policy that the amount withdrawn must be a divisor of the current amount (except the amount itself).
Ishaan wants his money as soon as possible, so he withdraws the maximum amount from his bank each day. Determine the number of days he will need to withdraw all of his money.
Note : If the remaining amount is 1, he can withdraw it.

Input : 
First line of input contains a single integer T denoting the number of test cases.
The only line of each test case contains an integer N.

Output : 
For each test case, print the required answer in a new line.

Constraints : 
1 <= T <= 200
1 <= N <= 10^12

Example : 
Input : 

3
12
21
9
Output : 
5
7
5

Explanation : 
Case 1 : 

N = 12
Withdraws 6
Remaining = 6
Withdraws 3
Remaining = 3
Withdraws 1
Remaining = 2
Withdraws 1
Remaining = 1
Withdraws 1
Remaining = 0

Case 2 : 
N = 21
Withdraws 7
Remaining = 14
Withdraws 7
Remaining = 7
Withdraws 1
Remaining = 6
Withdraws 3
Remaining = 3
Withdraws 1
Remaining = 2
Withdraws 1
Remaining = 1
Withdraws 1
Remaining = 0

Case 3 : 
N = 9
Withdraws 3
Remaining = 6
Withdraws 3
Remaining = 3
Withdraws 1
Remaining = 2
Withdraws 1
Remaining = 1
Withdraws 1
Remaining = 0

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Anubhav Goyal
Author: goyalanubhav11


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.