Skip to content

Instantly share code, notes, and snippets.

@leehs99
Created August 9, 2018 06:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leehs99/582b49ddfda989747b689f199c4ed3dd to your computer and use it in GitHub Desktop.
Save leehs99/582b49ddfda989747b689f199c4ed3dd to your computer and use it in GitHub Desktop.
import java.util.Scanner;
//Object : 이항 계수 1
//question : 자연수n 과 정수 k가 주어졌을 때 이항 계수nCk 를 구하는 프로그램을 작성하시오.
//Email : 99leehs@naver.com
public class Main11050 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
System.out.println(C(n)/(C(k)*C(n-k)));
}
static int C(int n) {
int num = 1;
for (int i = n; i >= 1; i--) {
num *= i;
}
return num;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment