I really don't understand why my answer is wrong, it works just fine for me. Could someone please help? asked 12 May '14, 17:45

Your code doesn't print anything for N = 1000000. answered 12 May '14, 17:56

The constraint is 1 ≤ N ≤ 1000000 but u r not considering the case where N = 1000000.... answered 12 May '14, 20:02

The constraint is on the input that input is N<=1000000 , not the answer . Answer can be greater than 1000000 . answered 12 May '14, 20:11
