Closest Divisor of given number problems

Revision en1, by SPyofgame, 2020-02-25 09:45:05

Question: Given two positive numbers N and M, find minimal |c — M| where N mod c = 0

Can we solve this problem in O(log (n)) or faster ?

Here is my approach in O(sqrt(n))

My code

Sorry for my bad English ;-;

If I have wrong something, please tell me. It is better to do that than just downvote me because I and someone will learn many new things <3

Tags #asking, #algorithms, #complexity, #optimization

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English SPyofgame 2020-02-25 09:45:05 772 Initial revision (published)