2/02/2012

C# Number Pattern (21)

C# Number Pattern (21)
C# Number Pattern (21)

 /* C# program to print the following pattern   
 1   
 2 6   
 3 7 10   
 4 8 11 13   
 5 9 12 14 15  */  
 namespace Patterns  
 {  
   class Program  
   {  
     static void Main(string[] args)  
     {  
       int i, j, k;  
       for (i = 1; i <= 5; i++)  
       {  
         k = i;  
         for (j = 1; j <= i; j++)  
         {  
           Console.Write(k);  
           k += 5 - j;  
         }  
         Console.WriteLine();  
       }        
     }  
   }  
 }  

No comments:

Post a Comment