Not So Easy Math

I have clearly understood the logic and tried to code it but my code does not pass one test case. Please help

in outer loop there should be i<=subsets