Faktöriyel Hesapla - CSharp


Recursive yapı ile faktöriyel hesabı yapan alternatif bir C# kodudur.

Kod


public double FaktoriyelHesapla(int sayi)
{
    double sonuc;
    if (sayi == 0 || sayi == 1) return 1;
    {
        sonuc = FaktoriyelHesapla(sayi - 1) * (sayi);
        return sonuc;
    }
}

Etiketler
csharp csharp metot örnekleri