PyramidNumbers

import java.util.*; public class PyramidNumbers { public PyramidNumbers() { System.out.println("Enter Number: "); Scanner sc = new Scanner(System.in); int number = sc.nextInt(); System.out.println("{" + number + "}"); System.out.println("{" + number + ", " + number + "}"); int[] prevLine = {number, number}; for(int i = 3; i < 7; i++){ int[] line = new int[i]; for(int b = 1; b < i - 1; b++){ line[0] = number; line[line.length - 1] = number; line[b] = prevLine[b] * prevLine[b-1]; } prevLine = 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.