We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi, I am taking this approach, when i get a number,
1. I ll take the sqrt of it and find the divisors having the smallest difference between them. in case(35, sqrt is 5.91 so i start from 5 and see if the number is divisible by 5.
if it is i will have the quotient (7) as the new number, increment cost and start from step 1.
if not, it should be a prime, so i will decrement it by 1, increment cost and use n-1 as the new number.
for this case 603900, i am getting 9 steps
603900->825->33->11->10->5->4->2->1->0, but the testcase expects 7. Is it possible to do it 7 steps, am i missing something?
Down to Zero II
You are viewing a single comment's thread. Return to all comments →
Hi, I am taking this approach, when i get a number, 1. I ll take the sqrt of it and find the divisors having the smallest difference between them. in case(35, sqrt is 5.91 so i start from 5 and see if the number is divisible by 5. if it is i will have the quotient (7) as the new number, increment cost and start from step 1. if not, it should be a prime, so i will decrement it by 1, increment cost and use n-1 as the new number.