+ 1

# No output for very large numbers, is this same with other devices?

The code works perfectly for smaller number but no output for very large numbers, maybe cos of my device. Just need someone to help me run the code to know what the output is. It's expected to return the largest prime factor. https://code.sololearn.com/W9vRO0aXWwbH/?ref=app

5 Answers

+ 5

There should be an output but you have to wait before seeing it, this can be explained due to the fact that your algo uses the for-loop which does not eases performance hence the calculations for a large number is very slow. You may need to consider the use of recursion to solve this

+ 2

Recursion consumes more memory than iteration but with a combo of a good optimization technique, it will solve this.
Also I like the idea of using the sieve of eratosthenes, I think it's faster since it's made by expert
https://code.sololearn.com/c95LM8oUXfY4/?ref=app

+ 1

Coder Kitten yeah, recursion is more time complex. I will try your method, thanks for the help

0

Ok. Thanks Mirielle[ InAcTiVe ]

0

Thanks Coder Kitten. This is actually a question from project euler. I will out some other methods also, maybe recursion as Mirielle[ InAcTiVe ] mentioned ealier.