I have attempted the problem 'SMALL' from SPOJ http://www.spoj.com/problems/SMALL/. Here http://ideone.com/oPuOvC) is the code.
It works fine on CodeBlocks but gives runtime error on ideone, due to overflow.
For example, there is no output for inputs like 5000 or 10000. How do I correct this?
P.S. I've just recently started coding in C++ having knowledge only in C so suggestions on making the code 'cleaner' will be helpful.