0

How can I minimize the execution time?

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

15th Jun 2020, 1:20 AM
Vera
Vera - avatar
6 Respostas
+ 1
Robin, no range limit.
15th Jun 2020, 1:09 PM
Vera
Vera - avatar
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!
16th Jun 2020, 12:52 AM
Vera
Vera - avatar
0
Thank you, Robin, so much! Gonna to implement it ASAP.
21st Jun 2020, 9:35 PM
Vera
Vera - avatar
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.
23rd Jun 2020, 3:00 AM
Vera
Vera - avatar
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!
24th Jun 2020, 12:58 AM
Vera
Vera - avatar
0
Oh, yhea, Robin)) It still follows me as well))
25th Jun 2020, 2:35 AM
Vera
Vera - avatar