1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rama09 [41]
3 years ago
12

I need to create a function that returns Pascal's Triangle with n rows, where n is an int argument.

Computers and Technology
1 answer:
Ede4ka [16]3 years ago
6 0

A function that returns Pascal's Triangle with n rows:

//import necessary headers

public class Pascal_Triangle {

   // calculate factorial  

   static int factorial(int n)

   {

       int fact = 1;

       int i;

       for(i=1; i<n; i++)

       {

           fact*=i;

       }

       return i;

   }

   // Actual code to display the //pascal triangle

   static void display(int n)  

   {

       int i;

       int line;

       for(line=1;line<=n;line++)

       {

           for(i=0;i<=line;i++)

           {

               System.out.print((factorial(line)/factorial(line-i) * factorial(i)) + " ");

           }

           System.out.println();

       }

   }

   // To read user input

   public static void main(String[] args){  

       BufferedReader breader=new BufferedReader(new InputStreamReader(System.in));

       int n;

       System.out.println("Enter the size for creating Pascal triangle");

       try {

           n = Integer.parseInt(breader.readLine());

       }

       catch(Exception e){

           System.out.println("Please enter a valid Input");

           return;

       }

       System.out.println("The Pascal's Triangle is");

       display(n);

   }

}

You might be interested in
Write the name of the tab, the command group, and the icon that you need to use to justify
Dafna11 [192]

Answer:

Tab: Home Tab

Command Group: Paragraph

Icon: Justify Icon

<em>The icon has no name; rather it is represented by 4 horizontal lines that are aligned on both edges</em>

<em />

Explanation:

To answer this question, I'll make use of the following attachment

<em>Where</em>

<em>1- represents the home tab</em>

<em>2 - represents the paragraph</em>

<em>3 - represents the justify icon</em>

<em />

3 0
4 years ago
Select the correct answer. Which keyboard feature is a form feed character? A. uppercase letters B. Control key C. lowercase let
Valentin [98]

Answer:

B . control key

Explanation:

dadadadads

4 0
3 years ago
I need someone who knows HTML to finish the code.
Maksim231197 [3]
I recommend you go to Stacks Overflow . There are many experienced coders there that would gladly answer your question.
7 0
4 years ago
Read 2 more answers
I DON"T GET THIS WHY IS THIS FUNNY
MakcuM [25]

Answer:

They deleted my answer what is funny?

Explanation:

8 0
3 years ago
HELP ASAP, AND YES I KNOW, WRONG CATEGORY. SORRY!
Anastasy [175]

Answer:

A. ensemble.

Explanation:

A musical ensemble can be defined as a group of people who play instrumental and vocal music. It is also known as a music group and carries a distinct name. The word ensemble is derived from the Middle French ensemblée, meaning together at the same time.

A rock band will come under the category of a musical ensemble as it is also a group of people performing instrumental music or vocal music.

Therefore, option A is correct.

3 0
3 years ago
Other questions:
  • Which view is used to allow a publisher to view facing pages of a publication at the same time?  NormalMaster PageTwo-Page Sprea
    9·1 answer
  • Store shelves are empty during periods of Excess Demand. What is another term for Excess Demand?
    8·1 answer
  • Your smartphone, digital camera, and printer are all part of a network in your workspace. What type of network is likely in use
    7·1 answer
  • . Write a code to define a linked list node using the above defined structure student (i.e. the data of the node is a student st
    11·1 answer
  • Personality traits such as thoughtfulness, empathy, self-control, and goal orientation belong to the _____ category.
    5·2 answers
  • What is the output of the following program?
    5·1 answer
  • What does a motherboard legacy BIOS do?
    11·1 answer
  • create your own min function that finds the minimum element in a list and use it in a separate function
    14·1 answer
  • Given the IPv4 address in CIDR notation 215.200.110.50/25, identify the subnet IDs.
    15·1 answer
  • Project: Digital Media and Business
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!