-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKombinasyon.java
More file actions
26 lines (24 loc) · 835 Bytes
/
Kombinasyon.java
File metadata and controls
26 lines (24 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.company;
import java.util.Scanner;
public class Kombinasyon {
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
System.out.print("Birinci Sayıyı Giriniz: ");
int sayi1 = scanner.nextInt();
System.out.print("İkinci Sayıyı Giriniz: ");
int sayi2 = scanner.nextInt();
int kombinasyon = kombinasyon(sayi1,sayi2);
System.out.println("C("+sayi1+","+sayi2+") = "+kombinasyon);
}
public static int kombinasyon(int sayi1, int sayi2){
int kombinasyon = faktoriyel(sayi1) / (faktoriyel(sayi2)*faktoriyel(sayi1-sayi2));
return kombinasyon;
}
public static int faktoriyel(int sayi){
if(sayi == 1){
return 1;
}else{
return sayi*faktoriyel(sayi-1);
}
}
}