Digit 9
You are given
The first line of input is an integer
In the given example,
N = 4.So, the output should be
* * * *
* *
* *
* * * *
*
*
* * * *Sample Input 1
4
Sample Output 1
* * * *
* *
* *
* * * *
*
*
* * * Sample Input 2
5
Sample Output 2
* * * * *
* *
* *
* *
* * * * *
*
*
*
* * * * *
Half Pyramid - 3
Given an integer
The first line of input is an integer
In the example, the given starting number is
10, and the number of rows in the pyramid is 5.So, the output should be
input-1
10
5
output-1
10
11 12
13 14 15
16 17 18 19
20 21 22 23 24
Sample Input 2
1
3
Sample Output 2
1
2 3
4 5 6
For example, an array A = [10, 20, 30] and a value x = 25.
We have values 10, 20, 30 at indices 0,1,2 respectively.
So there are 2 valid indices.
Sample Input 1
[1, 2, 3, 5, 7]
13
Sample Output 1
3
A number N is given as input. Write a program to check if N is positive or negative.
N = -12.5. As the value of N is less than 0, the output should be Negative.
Sum of the series
Write a program to find the sum
S of the series where S = x - x^3 + x^5 + ....... upto N terms.
Input
The first line of input is an integer
X. The second line of input is an integer N.
Explanation
If we take
X value as 2 in the series upto 5 terms.
Then the series is 2 - 23 + 25 - 27 + 29
So, the output should be
410.
Sample Input 1
2
5
Sample Output 1
410
Sample Input 2
3
2
Sample Output 2
-24
Inverted Solid Right Triangle
Given an integer number
N as input. Write a program to print the right-angled triangular pattern of N lines as shown below.
Note: There is a space after each asterisk (*) character.
Input
The first line of input is an integer
N.
Explanation
In the given example the solid right angled triangle of side
4. Therefore, the output should be
* * * *
* * *
* *
*
Sample Input 1
4
Sample Output 1
* * * *
* * *
* *
*
Sample Input 2
5
Sample Output 2
* * * * *
* * * *
* * *
* *
*
Solid Right Angled Triangle - 2
Given an integer number
N as input. Write a program to print the right-angled triangular pattern of N lines as shown below.
Note: There is a space after each asterisk (*) character.
Input
The first line of input is an integer
N.
Explanation
In the given example, the solid right-angled triangle of side
5. Therefore, the output should be
*
* *
* * *
* * * *
* * * * *
Sample Input 1
4
Sample Output 1
*
* *
* * *
* * * *
Sample Input 2
6
Sample Output 2
*
* *
* * *
* * * *
* * * * *
* * * * * *
Right Angled Triangle - 3
Given an integer number
N as input. Write a program to print the right-angled triangular pattern of N rows as shown below.
Input
The first line of input is a positive integer.
Explanation
For example, if the given number is
5, the output should be
______
| /
| /
| /
| /
|/
Sample Input 1
5
Sample Output 1
______
| /
| /
| /
| /
|/
Sample Input 2
7
Sample Output 2
________
| /
| /
| /
| /
| /
| /
|/
Hollow Right Triangle - 2
Given an integer number
N as input. Write a program to print the hollow right-angled triangular pattern of N lines as shown below.
Note: There is a space after each asterisk (*) character.
Input
The first line of input is an integer
N.
Explanation
In the given example the hollow right angled triangle of side
5. Therefore, the output should be
*
* *
* *
* *
* * * * *
Sample Input 1
4
Sample Output 1
*
* *
* *
* * * *
Sample Input 2
5
Sample Output 2
*
* *
* *
* *
* * * * *