Skip to content

Instantly share code, notes, and snippets.

@ouzdev
Last active December 21, 2019 10:31
Show Gist options
  • Save ouzdev/5b9e45edaabb3be958c4d96b0f5ffdcc to your computer and use it in GitHub Desktop.
Save ouzdev/5b9e45edaabb3be958c4d96b0f5ffdcc to your computer and use it in GitHub Desktop.
Faktöriyel, Permütasyon, Kombinasyon Hesaplama
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace faktoriyel_kombinasyon_permutasyon_metod
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public double Faktoriyel(double sayi)
{
double sonuc = 1;
for (double i = sayi; i <= sayi; i--)
{
if (i == 0)
{
break;
}
sonuc *= i;
}
return sonuc;
}
public double Permutasyon(double n, double r)
{
double n_sonuc = Faktoriyel(n);
double n_r =n-r;
double n_r_sonuc=Faktoriyel(n_r);
double sonuc = n_sonuc / n_r_sonuc;
return sonuc;
}
public double Kombinasyon(double n,double r)
{
double n_sonuc = Faktoriyel(n);
double r_sonuc = Faktoriyel(r);
double n_r_eksi = n - r;
double n_r_f = Faktoriyel(n_r_eksi);
double r_f_nrf = r_sonuc * n_r_f;
double sonuc= n_sonuc / r_f_nrf;
return sonuc;
}
private void btn_hesapla_Click(object sender, EventArgs e)
{
if (rdb_faktoriyel.Checked)
{
txt_sayi_2.Visible = false;
btn_hesapla.Visible = true;
double sayi = Convert.ToDouble(txt_sayi_1.Text);
MessageBox.Show(Faktoriyel(sayi).ToString());
}
else if (rdb_permutasyon.Checked)
{
btn_hesapla.Visible = true;
double sayi = Convert.ToDouble(txt_sayi_1.Text);
double sayi2 = Convert.ToDouble(txt_sayi_2.Text);
MessageBox.Show(Permutasyon(sayi, sayi2).ToString());
}
else if (rdb_kombinasyon.Checked)
{
double sayi = Convert.ToDouble(txt_sayi_1.Text);
double sayi2 = Convert.ToDouble(txt_sayi_2.Text);
MessageBox.Show(Kombinasyon(sayi, sayi2).ToString());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment