Number Pattern - Coder's point

Saturday, March 16, 2019

Number Pattern

 /*22345  
   33345  
   44445  
   55555*/  
 public class num_pattern  
 {  
   void pattern()  
   {  
     int i,b,c,p=2;  
     for( i=1;i<=5;i++){  
       for( b=1;b<=i ;b++)  
         System.out.print(i);  
       for( c=p;c<=5;c++)  
         System.out.print(c);  
       System.out.println();  
       p=p+1;  
     }  
   }  
   public static void main()  
   {  
     num_pattern ob = new num_pattern();  
     ob.pattern();  
   }  
 }  
OUTPUT:
22345  
33345  
44445  
55555

No comments:

Post a Comment