Functions and Recursions – Algebra – Problem #1

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: medium

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 PDS 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 LAB 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. Write a recursive function the determines if an input integer m is a PDS number or not. 3. Write a recursive function to determine if an input integer m is a LAB number or not. 4. Write a recursive function to print all PDS numbers from 1 to n. 5. Write a recursive function to print all LAB numbers from 1 to n. 6. Write a recursive function such that if the number n is both a PDS number and a LAB number then an n-bow pattern is printed. 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-Im Proper commenting, indentation and output commands carry marks.

Back to Lab Problems
Functions and Recursions/Algebra/Problem #1

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #1

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.