Brute force Python solution (65 marks) : Click Here
Optimised C++ solution using smallest prime factor (100 marks ) : Click Here
Prerequisite: “https://www.geeksforgeeks.org/prime-factorization-using-sieve-olog-n-multiple-queries/”
EDIT : For all those who are saying why my brute force c++ (store product and check) , gives WA , this is bcz of overflow of long long int too (for ex take numbers from 1 to 50 means 50! not possible to store)