Created
August 9, 2018 06:18
-
-
Save leehs99/582b49ddfda989747b689f199c4ed3dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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