How can I minimize the execution time? | Sololearn: Learn to code for FREE!

0

# How can I minimize the execution time?

The task description provided in the code. https://code.sololearn.com/cdCLiW0JkK52/?ref=app Thank you.

6/15/2020 1:20:21 AM

Vera

+1

Robin, no range limit.

0

Thank you, Robin! I tested both of your solutions (you’re amazing!), everything works! But looks like I need to include all of them in the code, depending on the number range. Thank you again!

0

Thank you, Robin, so much! Gonna to implement it ASAP.

0

Actually, I figured out, that odd numbers like 9, for example, are alredy have everything in themselves: 9 = 4 + 5, where 9 + 4 ** 2 = 5 ** 2. You can easily check all other odd numbers in range of 100 at least. But in a matter to find the smallest perfect square, we faced again to the iteration which takes time.

0

At least it should work for the prime numbers, as you mentioned above, so we don’t have to iterate through in this case. Very interesting task, are you agree? Actually, the task is one of the Katas in codewars. You can try to implement the solution by yourself, if you intrested in. But definitely, I would prefer that you will not share the successfully executed code with me. I gonna handle with it by myself. I mean, with your previous hints, for shure! which I got enogh and really appreciate your help)) Thank you again, Robin. Good luck!

0

Oh, yhea, Robin)) It still follows me as well))