Sunday, March 11, 2018

Number Pattern 1

Number Pattern 1
Send Feedback

Print the following pattern for the given N number of rows.

Pattern for N = 4
1
11
111
1111
Input format :
Integer N (Total no. of rows)
Output format :
Pattern in N lines
Sample Input :
5
Sample Output :
1
11
111
1111
11111

import java.util.Scanner;

public class Main
{

public static void main(String[] args)
{
   int i,j;
Scanner s=new Scanner(System.in);
int n = s.nextInt();
    for(i=1;i<=n;i++)
    {
    for(j=1;j<=i;j++)
    {
        System.out.print("1");
    }
    System.out.println();
       
    }
}
}

No comments:

Post a Comment