import java.util.*;
public class Pyramid
{
ArrayList <Integer> Pline = new ArrayList<Integer>();
ArrayList <Integer> Cline = new ArrayList<Integer>();
public Pyramid()
{
int lines = 5;
Pline.add(2);
System.out.println(Pline);
Pline = new ArrayList<Integer>();
Pline.add(2);
Pline.add(2);
System.out.println(Pline);
while (lines>0){
Cline = new ArrayList<Integer>();
Cline.add(2);
for(int i = 0; i<Pline.size()-1; i++){
Cline.add(Pline.get(i)*Pline.get(i+1));
}
Cline.add(2);
System.out.println(Pline) ;
Pline = new ArrayList<Integer>();
for(int j=0; j<Cline.size(); j++){
Pline.add(Cline.get(j));
}
lines--;
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.