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
jekas [21]
3 years ago
9

Write a recursive method called permut that accepts two integers n and r as parameters and returns the number of unique permutat

ions of r items from a group of n items. For given values of n and r, this value P(n, r) can be computed as follows:
n!/(n - r)!
For example , permut (7, 4) should return 840.
Computers and Technology
1 answer:
tangare [24]3 years ago
8 0

Answer:

Following are the code to the given question:

public class Main//defining a class Main

{

static int permut(int n, int r)//defining a method permut that holds two variable

{

return fact(n)/fact(n-r);//use return keyword to return calcuate value

}

static int fact(int n)//defining a fact method as recursive to calculate factorials

{

return n==0?1:n*fact(n-1);//calling the method recursively

}

public static void main(String[] abs)//main function

{

//int n=7,r=4;//defining integer variable

System.out.println(permut(7,4));//use print method to call permut method and print its values

}

}

Output:

840

Explanation:

Following is the explanation for the above code.

  • Defining a class Main.
  • Inside the class two methods, "permut and fact" were defined, in which the "permut" accepts two values for calculating its permutated value, and the fact is used for calculates factorial values recursively.
  • At the last, the main method is declared, which uses the print method to call "permut" and prints its return values.
You might be interested in
Why do i get message notifications but when i click on it it says i have no new messages?
jeka57 [31]

Answer:

Might just be a glitch you should try to ignore it for the time being or you can log out then log in to your acc

Explanation:

good luck

4 0
3 years ago
Can i add ADSence on bangla content in blogsopt website?
Inga [223]

Answer:

I do not think you can! However, I am not sure since I mainly use Wix!!!

Explanation:

8 0
3 years ago
This career involves answering questions about computer parts and trouble shooting broken computers? Video game designer, comput
adelina 88 [10]

Computer retail sales associate is my best guess. :)

3 0
3 years ago
Who needs to be involved when assembling business solutions that include hardware and software?
sveta [45]
Software engineer i would say
5 0
3 years ago
Read 2 more answers
Which PlayStation was the first to allow connection between it and computer network
Bezzdna [24]

If you're talking about connecting to the internet internet, it would be the PS2. You could buy an adapter for an ethernet cable to allow for online play.

4 0
4 years ago
Other questions:
  • Give a big-O estimate for the number of comparisons used by the algorithm that determines the number of 1s in a bit string of le
    9·2 answers
  • Write a one-line program to output the following haiku.
    11·2 answers
  • What is the difference between a software package and integrated software
    7·1 answer
  • "You are setting up a new subnetwork on an existing network. Management has asked that you use existing cabling that the company
    14·1 answer
  • 5 provisions of computer ethics
    6·1 answer
  • bro this scared me, i thought i just got hacked, could someone explain why when i went to ask a question, it kicked me out my ac
    9·2 answers
  • Suppose we want to adjust the page numbering for our Works Cited section so that it starts over at page 1. Is this possible to d
    12·2 answers
  • Which formatting option(s) can be set for Conditional Formatting rules?
    8·2 answers
  • WILL GIVE BRAINLIEST!!!!!
    8·1 answer
  • g Write a function number_of_pennies() that returns the total number of pennies given a number of dollars and (optionally) a num
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!