using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace p20_recursivitate
{ //3.10.2013
class Program
{
static int suma_cif(int n)
{
if (n == 0) return 0;
else return n % 10 + suma_cif(n / 10);
}
static int fib(int n)
{
if (n <= 1) return 1;
else return fib(n - 1) + fib(n - 2);
}
static int cmmdc(int a, int b)
{
if (b == 0) return a;
else return cmmdc(b, a % b);
}
static void Main(string[] args)
{
Console.WriteLine(suma_cif(431));
Console.WriteLine(fib(6));
Console.WriteLine(cmmdc(45,70));
Console.ReadKey();
}
}
}
|