0% found this document useful (0 votes)
101 views1 page

Java Piramide de Pascal

The document is a Java program that generates Pascal's triangle up to a specified exponent limit. It prompts the user to input an exponent limit, creates a 2D array of that size to store the triangle values, calculates each element by summing the above and left elements, and prints out the completed triangle with spacing for alignment.

Uploaded by

Pablo Contreras
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views1 page

Java Piramide de Pascal

The document is a Java program that generates Pascal's triangle up to a specified exponent limit. It prompts the user to input an exponent limit, creates a 2D array of that size to store the triangle values, calculates each element by summing the above and left elements, and prints out the completed triangle with spacing for alignment.

Uploaded by

Pablo Contreras
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package pascal; import java.util.

Scanner; public class Pascal { public static void main(String[] args) { Scanner miScan = new Scanner(System.in); System.out.print("Ingrese el exponete limite del Triangulo de Pascal:"); int exp = miScan.nextInt(); int[][] triangulo = new int[exp + 1][exp + 1]; for (int x = 0; x < triangulo.length; x++) { for (int y = 0; y <= x; y++) { if (x == y || y == 0) triangulo[x][y] = 1; else { triangulo[x][y] = triangulo[x - 1][y - 1] + triangulo[x - 1] [y]; } } } for (int x = 0; x < triangulo.length; x++) { for (int esp = 0; esp < exp; esp++) System.out.print(" "); for (int y = 0; y <= x; y++) { System.out.print(triangulo[x][y] + " "); } System.out.println(); exp = exp - 1; } } }

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy