wap to print the following series
*
**
***
****
*****
Answers
Answer:
Input: N = 4
Output: 2, 1, 4, 3
Explanation:
Nth Term = (N % 2 == 0) ? (N - 1) : (N + 1)
1st term = (1 % 2 == 0) ? (1 - 1) : (1 + 1)
= (1 + 1)
= 2
2nd term = (2 % 2 == 0) ? (2 - 1) : (2 + 1)
= (2 - 1)
= 1
3rd term = (3 % 2 == 0) ? (3 - 1) : (3 + 1)
= (3 + 1)
= 4
4th term = (4 % 2 == 0) ? (4 - 1) : (4 + 1)
= (4 - 1)
= 3
Therefore, Series = 2, 1, 4, 3
Input: N = 7
Output: 2, 1, 4, 3, 6, 5, 8
Explanation:
Answer:
First of all it is a pattern not a series.
your code in JAVA:
class pattern
{
public static void main ()
{
int i,j;
for (i=0;i <=4;i++)
{
for (j=0;j <=i;j++)
System.out.print("*");
System.out.println ();
}}}
Your code in PYTHON :-
for i in range (1,6): print (i* "*")
Explanation:
I hope my answers helps you
Don't forget to mark me the Brainliest
Bye