C Program to print all magic number till N

OUTPUT: