NUMFACT wa

my approach is similar to editorial.But it shows WA in several cases.Whats wrong with my approach?>

64Tmmy - Online C++0x Compiler & Debugging Tool - Ideone.com