Write a program in Java to print the following Pattern
1
12
123
1234
12345
Coding must be easily understood
Answers
Answer:
Hey mate ✌️
Explanation:
public class Pattern
{
public static void main ()
{
for ( int i= 1 ; i <= 5; i ++)
{
for ( int j= 1 ; i <= i; i ++)
System.out.print("pattern:" +j );
}
System.out.println( );
}
}
}
_____________________________
Output :
1
12
123
1234
12345
Hope it helps ❣️❣️
Answer:
write a program in java to print the given series✔️
import java.util.Scanner;
public class Series
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the number of terms: ");
int n = sc.nextInt();
int s = 0, c;
// s for terms of series, c for counter to generate n terms
for (c = 1; c <= n; c++) {
s = s * 10 + c;
System.out.print(s + " ");
}
}
}
Output:
Enter the number of terms: 6
1, 12, 123, 1234, 12345, 123456.