Loops – Arithmetic – Problem #3
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
Submit one (single) C program. Definitions 1. A positive integer is called a PDS number if the number is equal to the sum of the factorial of its digits. For example, 1 (1 = 1!), 2 (2 = 2!), 145 (145 = 1! + 4! + 5!) are IIT numbers. 2. A positive integer is called a LAB number if the number is equal to the sum of its divisor except itself. For example, 6 (6 = 1 + 2 + 3), 28 = (1 + 2 + 4 + 7 + 14) are KGP numbers. 3. An n-bow pattern is a pattern of height 2n-1, where the first row has n stars, second row has n— 1 stars, etc., n-1th row has 2 stars, nth row has 1 star, n+1th row has 2 stars, etc., and 2n-1th row has n stars. *** ** * ** *** The above pattern is a 3-bow pattern. Write a C program to perform the following tasks. 1. Take as input an integer n. 2. Print all PDS numbers from 1 to n. 3. Print all LAB numbers from 1 to n. 4. If the number n is both a PDS number and a LAB number then print an n-bow pattern. You may need to use math library function : #include <math.h> If you want to compile useing the terminal then use the command gcc./program.c -lm Proper commenting, indentation and output commands carry marks.