waltermilner

Untitled

Aug 17th, 2016
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public class Test {
  2.  
  3.   // calculate n to the power n
  4.   static long nToPower(int n)
  5.   {
  6.     return (long) Math.pow(n,n);
  7.   }
  8.  
  9.   public static void main(String[] args) {
  10.    
  11.     final int LIMIT=8; // number of rows required
  12.    
  13.     for (int row=LIMIT; row>0; row--) // each row
  14.     {
  15.       for (int i=1; i<=row; i++) // work along row
  16.         System.out.print(nToPower(i)+" ");
  17.       System.out.println(); // new line
  18.     }
  19.    
  20.    
  21.   }
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment