domingo, 13 de noviembre de 2011

En este programa utilizamos recursividad

class Matematicas{


{


string x;public int Factorial_R(int n)int f = 1;if (n == 0 || n == 1)return f;elsef = n * Factorial_R(n - 1);

}

{


return f;public int Sumatoria_R(int n)int f = 0;if (n == 0 || n == 1)return f;elsef = n + Factorial_R(n - 1);

}

{

return f;public static int Fibonacci(int n)if (n == 1 || n == 2)return 1;else{


}
}

{

int resul = Fibonacci(n - 1) + Fibonacci(n - 2);return resul;public int Combinacion_R(int n, int r)if ((n == r) || (r == 0) || (n == 1))return 1;else
}

{
x +=

Invertir(n / 10);

}
}

public partial class Form1 : Form{

{
InitializeComponent();
}


{



}

{
}

{



{

res=obb.Factorial_R(n);
textBox7.Text = res.ToString();
}

{

textBox7.Text = obb.Invertir(n).ToString();
}

{

res =
textBox7.Text = res.ToString();
}


{
textBox2.Visible =


res = obb.Combinacion_R(n, n2);
textBox7.Text = res.ToString();
}

}
public Form1()private void button1_Click(object sender, EventArgs e)private void button2_Click(object sender, EventArgs e)private void button2_Click_1(object sender, EventArgs e)Matematicas obb = new Matematicas();int res=0;if (comboBox1.SelectedIndex == 0)int n = Convert.ToInt32(textBox1.Text);if (comboBox1.SelectedIndex == 1)int n = Convert.ToInt32(textBox1.Text);if (comboBox1.SelectedIndex == 2)int n = Convert.ToInt32(textBox1.Text);Matematicas.Fibonacci(n);if (comboBox1.SelectedIndex == 3)false; ;int n = Convert.ToInt32(textBox1.Text);int n2 = Convert.ToInt32(textBox2.Text);
return Combinacion_R(n - 1, r) + Combinacion_R(n - 1, r - 1);public string Invertir(int n)Convert.ToString(n % 10) + " ";if (n >= 10)return x;

No hay comentarios:

Publicar un comentario