DevJourney · code I wrote while learning

README.md

1.0 KB

Single File Programming Question

Problem statement

Mandy wants to calculate the factorial of a number and the sum of its digits. Help her with a program for the same using a call-by-reference function.

Write a program that takes an integer as input and computes both the factorial and the sum of its digits.

Input format :

The input consists of an integer N representing the number for Mandy's calculations.

Output format :

The first line prints "Factorial: " followed by an integer which is the factorial of the given number N.

The second line prints "Sum of digits of the factorial: " followed by an integer which is the sum of the digits of the factorial.

Refer to the sample output for the formatting specifications.

Code constraints :

In this scenario, the test cases fall under the following constraints:

1 ≤ N ≤ 10

Sample test cases :

Input 1 :

5

Output 1 :

Factorial: 120 Sum of digits of the factorial: 3

Input 2 :

9

Output 2 :

Factorial: 362880 Sum of digits of the factorial: 27