Permutations Program

Collapse Content

Permutations are the number of possible orders for a given group of elements. You can determine the permutation by multiplying by the number of possible choices for each selection.

For example, let's say you are given 4 distinct elements, and want to know how many ways you can arrange 3 of them. You can pick from 4 elements for the first choice, 3 for the second, and 2 for the third:

4 Permute 3 = 4 * 3 * 2 = 24 possible ways

(See below for additional examples.)

Challenge Formula
The general Permutation formula for a permute b is:
a * (a-1) * (a-2)... (until you've multiplied b elements.)

Can you calculate a permute b?


Given two numbers a and b, calculate and return a Permute b as above.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.


  • import java.util.Scanner;

    public class Main {

    static int doStuff(int a, int b)
            int count=b;
            int  ans=1;
         for(int i=0;i<b;i++)
  • That was tricky. Took me! my code

Contact Us
Sign in or email us at [email protected]