Menu Close

Number Pattern 111111 in Java …ftc

Write a program to print following outputs.
1111111
1111122
1111333
1114444
1155555
1666666
7777777

Input:
7

Output:
1111111
1111122
1111333
1114444
1155555
1666666
7777777
import java.io.*;
import java.util.*;
public class temp{
  public static void main(String[] args){
    int n;
    Scanner scan = new Scanner(System.in);
    System.out.print("Enter any number:  ");
    n = scan.nextInt();

    for(int i=1;i<=n;i++)
    {
      for(int j=i;j<n;j++){
        System.out.print("1");
      }
      for(int k=1;k<=i;k++){
        System.out.print(i);
      }
      System.out.println();
    }

  }
}
   

INPUT_1:
Enter any number:  7

OUTPUT:
1111111
1111122
1111333
1114444
1155555
1666666
7777777


INPUT_2:
Enter any number:  5

OUTPUT:
11111
11122
11333
14444
55555


INPUT_3:
Enter any number:  6

OUTPUT:
111111
111122
111333
114444
155555
666666


INPUT_4:
Enter any number:  8

OUTPUT:
11111111
11111122
11111333
11114444
11155555
11666666
17777777
88888888


INPUT_5:
Enter any number:  10

OUTPUT:
1111111111
1111111122
1111111333
1111114444
1111155555
1111666666
1117777777
1188888888
1999999999
10101010101010101010


INPUT_6:
Enter any number:  20

OUTPUT:
11111111111111111111
11111111111111111122
11111111111111111333
11111111111111114444
11111111111111155555
11111111111111666666
11111111111117777777
11111111111188888888
11111111111999999999
111111111110101010101010101010
1111111111111111111111111111111
11111111121212121212121212121212
111111113131313131313131313131313
1111111414141414141414141414141414
11111151515151515151515151515151515
111116161616161616161616161616161616
1111717171717171717171717171717171717
11181818181818181818181818181818181818
119191919191919191919191919191919191919
2020202020202020202020202020202020202020


ILLUSTRATION

Executed using javac on linux terminal