A faster way to compute largest prime factor (Again, but a lot better)
It's buggy. Consider input 8.



Also, consider an input which is a very large prime. E.g. 2147483647. Your current code would take about 2147483645 trial divisions. It's possible to do it with only 46340 trial divisions while keeping the code very simple. Can you see how?


   Hint: 46340 is the square root, rounded down.


And that's easily optimised to 23171. Can you see how?


   Hint: only one prime is even.