Ugly Numbers @hb

https://hack.codingblocks.com/contests/c/452/1271
https://ide.codingblocks.com/#/s/31654

output is coming correct. Then what’s wrong?

Question says that only prime factors are 2,3,5. But your code considers 14 as ugly number. As 14%2==0 is satisfied.

Try factorising numbers

By “factorising” you mean prime factorization?

Yes, and if different prime factors are only 2,3,5. Then the number is a lucky number.