Find minimum steps to reduce to one

Revision en3, by tatya_bichu, 2018-07-30 06:13:00

Given T test cases T<=100000 In each test case given a positive integer A.A<=100000 You can perform any of the following steps(one of them):.

1) decrement A by 1.

2) increment A by 1.

3) divide A by one of it's prime factor.

Find minimum number of steps to reduce A to 1. 1) it is best to divide by max prime factor or finding nearest prime number whichever is minimum. This is codeforces problem but I can't find it

Tags #recursion, #primes, factor

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English tatya_bichu 2018-07-30 06:13:00 9 Tiny change: 'integer A.\nYou can ' -> 'integer A.A<=100000\nYou can '
en2 English tatya_bichu 2018-07-29 18:32:13 16
en1 English tatya_bichu 2018-07-29 18:31:31 454 Initial revision (published)