Pascal

/** * Write a description of class Pascals here. * * @author (your name) * @version (a version number or a date) */ import java.util.*; public class Pascals { // instance variables - replace the example below with your own public Pascals() { // initialise instance variables ArrayList<Integer> array = new ArrayList<Integer>(); int x = 2; int[] last = {2, 2}; System.out.println("[2]"); System.out.println("[2, 2]"); for(int i = 3; i < 7; i++){ int[] line = new int[i]; for(int b = 1; b < i - 1; b++){ line[0] = x; line[line.length - 1] = x; line[b] = last[b] * last[b-1]; } last = line; System.out.println(Arrays.toString(line)); } } }

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.