Answers for "suma de n numeros recursiva"

C
0

suma de n numeros recursiva

/*Construir una función recursiva que calcule la suma de los n primeros números
naturales.
*/
int suma(int n){
  int res = 0;

  if(n == 0){//Caso base
    res = 0;
  }else{
    res = n + suma(n - 1);
  }

  return res;
}
Posted by: Guest on June-27-2020

Code answers related to "suma de n numeros recursiva"

Code answers related to "C"

Browse Popular Code Answers by Language