Write a program which takes an integer as input and computes the sum of the factorial of each digit. For example, assume that the user enters "572" as the input. For each digit of the integer, you will compute the factorial. Then you will compute the sum of these factorials: 5! + 7! + 2! = 120 + 5040 + 2 = 5162.
Input | Output |
---|---|
572 | 5162 |
27 | 5042 |
What about the sum of the factorial of only odd digits?
a. Write a program which takes an integer as input and prints whether the number is prime or not.
Input | Output |
---|---|
7 | prime |
8 | not prime |
b. Write a program which takes an integer as input and prints prime numbers up to that integer.
Input | Output |
---|---|
11 | 2 3 5 7 |
15 | 2 3 5 7 11 13 |
a. Write a program which takes two positive integers as N and M then prints a rectangle with size NxM.
Input | Output |
---|---|
3 4 | **** **** **** |
2 6 | ****** ****** |
b. Write a program which takes two positive integers as N and M then prints a rectangle with size NxM which has stars (*) at borders, and lines (-) inside.
Input | Output |
---|---|
3 3 | *** *-* *** |
4 5 | ***** *---* *---* ***** |
a. Write a program to display a right angle triangle with N number of rows, like below.
Input | Output |
---|---|
3 | 1 12 123 |
5 | 1 12 123 1234 12345 |
Hint
At each row, we iterate from 1 to the row number.b. Write a program which takes two integer as N and x and display a right angle triangle with N number of rows formed by powers of x as follows:
Input | Output |
---|---|
3 4 | 4 4 16 4 16 64 |
4 3 | 3 3 9 3 9 27 3 8 27 81 |
Hint
At each row, we take power of input integer from once to the row number times.Write a program which takes an integer as input and prints an upper triangle of letters as follows:
Input | Output |
---|---|
5 | A B C D E B C D E C D E D E E |
3 | A B C B C C |
Write a program which takes an integer as input and prints the following pattern:
Input | Output |
---|---|
5 | * ** *** **** ***** |
3 | * ** *** |