refacotr largest prime factor calculation