Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test {
- // calculate n to the power n
- static long nToPower(int n)
- {
- return (long) Math.pow(n,n);
- }
- public static void main(String[] args) {
- final int LIMIT=8; // number of rows required
- for (int row=LIMIT; row>0; row--) // each row
- {
- for (int i=1; i<=row; i++) // work along row
- System.out.print(nToPower(i)+" ");
- System.out.println(); // new line
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment