Runtime error - Ugly numbers

Why am I getting run time error in Ugly numbers?

Link to code : https://ide.codingblocks.com/s/277856

@Avi-Kasliwal-315786729062203 n can be upto 10000 but you are taking your count upto only 1001, increase your count limit and your code will work fine.