. v3
Can you make equations haha?
Or, how about the quadratic equation, can you make it do that?
``` import java.util.Scanner; public class PermutationTest{ public static void main(String[] args) { int k, n; Scanner input = new Scanner(System.in); System.out.print("n: "); n = input.nextInt(); System.out.print("k: "); k = input.nextInt(); System.out.println(String.format("%d permute %d = %d", n, k, permute(n,k))); } public static int permute(int n, int k) { int result = 1; for (k = k+1; k <= n; k++) { result *= k; } return result; } } ```
how would you change this program to do quadratic equation?
No clue :d
How would you change it to give you combination, like n choose k?
"%d permute %d = %d
Maybe change that?
my permutation formula is incorrect!
Yeah, I was confused it wasn't working lol
So, how would you try to fix it?
um
Which lines of code do you not understand?
ask about one line at a time.
Well I thought something might be missing here, n = input.nextInt();
such as?
The formula for permutations is: \[\Large ^nP_k = \prod_{i=n-k+1}^ni \]
What ever you want to put for n and k
Note that \[\Large n! = \prod_{i=1}^ni \]In short, \(n! = ^nP_n\).
batman, does it not let you enter a number?
Yeah it does lol
anyway... you haven't asked any question.
That's because I'm still experimenting lol, I'm not exactly sure what I'm doing yet.
Alright, think I'm done with this for tonight, thanks @wio @Kainui @tanya123
Join our real-time social learning platform and learn together with your friends!