factorion
C++
#include <iostream>
using namespace std;
//FACTORION: suma de los factoriales de sus dígitos
int factorial(int n);
int digits(uint n){
int cantidad = 1;
int numero = n;
while(numero/10 != 0){
numero = numero/10;
cantidad++;
}
cout << "Numero de digitos: " << cantidad << endl << endl;
int array[cantidad];
int i = 0;
while(n > 0){
int r = n % 10;
array[i] = r;
cout << "array[" << i << "] is " << array[i] << endl;
i++;
n = n / 10;
}
int fact = 0, solucion = 0;
for(int u = 0; u <= cantidad; u++){
fact = factorial(array[u]);
solucion = solucion + fact;
}
cout << endl << "solucion: " << solucion << endl;
return fact;
}
int factorial(int n){
int fact;
if(n == 0){
fact = 1;
}else{
fact = n * factorial(n-1);
}
return fact;
}
int main(){
cout << "FUNCION FACTORIÓN" << endl;
cout << digits(215) << endl;
return 0;
}
Also in C++:
- Title
- c++ set add element
- Category
- C++
- Title
- convert string to stream c++
- Category
- C++
- Title
- what is time complexity of insertion sort
- Category
- C++
- Title
- binary tree deletion
- Category
- C++
- Title
- Find a element in a map C++
- Category
- C++
- Title
- cin.fail()
- Category
- C++
- Title
- c++ vector lower_bound index
- Category
- C++
- Title
- c++ initialize array
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- ue4 c++ overlapping functions cpp setup
- Category
- C++
- Title
- arduino delay millis
- Category
- C++
- Title
- euler phi gfg
- Category
- C++
- Title
- max in c++
- Category
- C++
- Title
- cpp loop through object
- Category
- C++
- Title
- how to compare lower case character to uppercase cpp
- Category
- C++
- Title
- cpp pi from acos
- Category
- C++
- Title
- singleton c++
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- generate random double c++
- Category
- C++
- Title
- c++ declare char
- Category
- C++
- Title
- c++ string to integer without stoi
- Category
- C++
- Title
- find in set of pairs using first value cpp
- Category
- C++
- Title
- c++ do while loop
- Category
- C++
- Title
- filling 2d array with 0 c++
- Category
- C++
- Title
- c++ menu selection with arrow keys
- Category
- C++
- Title
- map vs unordered_map in C++
- Category
- C++
- Title
- set lower bound c++
- Category
- C++
- Title
- c++ reset stream
- Category
- C++
- Title
- c++ ros subscriber
- Category
- C++
- Title
- ue4 modular character
- Category
- C++
- Title
- c++ typeid get type name
- Category
- C++
- Title
- object reference not set to an instance of an object c#
- Category
- C++
- Title
- c++ give options
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- copy a part of a vector in another in c++
- Category
- C++
- Title
- mark occurances of elements in array cpp
- Category
- C++
- Title
- how to turn int into string c++
- Category
- C++
- Title
- linear search in c++
- Category
- C++
- Title
- c++ how to loop through a vector but not the last element
- Category
- C++
- Title
- C++ user input
- Category
- C++
- Title
- converting char to int in c++
- Category
- C++
- Title
- ios_base::sync_with_stdio(false);cin.tie(NULL);
- Category
- C++
- Title
- c++ class member initialization
- Category
- C++
- Title
- primeros numeros primos
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- c++ ternary operator
- Category
- C++
- Title
- dfs in c++
- Category
- C++
- Title
- solve linear equations geeksforgeeks
- Category
- C++
- Title
- best fit algorithm
- Category
- C++
- Title
- memset
- Category
- C++
- Title
- sieve of eratosthenes c++
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- c++ show time elapsed
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- nearest integer rounding in c++
- Category
- C++
- Title
- c++ loop through array
- Category
- C++
- Title
- getline not working c++
- Category
- C++
- Title
- how the theam are store in database
- Category
- C++
- Title
- map.erase in c++
- Category
- C++
- Title
- compare values within within a vector c++
- Category
- C++
- Title
- char size length c++
- Category
- C++
- Title
- how use global variables instead of local in c++
- Category
- C++
- Title
- how to print for limited decimal values in c++
- Category
- C++
- Title
- matrix eigen c++ example
- Category
- C++
- Title
- how to make loop in c++
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- cs1955 unity vector3
- Category
- C++
- Title
- function declerations in C++
- Category
- C++
- Title
- double max value c++
- Category
- C++
- Title
- initialize array c++
- Category
- C++
- Title
- min heap declaration in c++ stl
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- c++ read file line by line
- Category
- C++
- Title
- remove item from layout
- Category
- C++
- Title
- built in function in c++ for binary to decimal
- Category
- C++
- Title
- c++ remove space from string
- Category
- C++
- Title
- chess perft 5
- Category
- C++
- Title
- cube mapping sdl
- Category
- C++
- Title
- how to make string get spaces c++
- Category
- C++
- Title
- simple timer arduino blynk library error
- Category
- C++
- Title
- c++ declare variable
- Category
- C++
- Title
- zeros of array c++
- Category
- C++
- Title
- ceil in c++
- Category
- C++
- Title
- string substr c++
- Category
- C++
- Title
- how to sort vector in c++
- Category
- C++
- Title
- Create a program that finds the minimum value in these numbers
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- map arduino
- Category
- C++
- Title
- dynamic 2d array c++
- Category
- C++
- Title
- private and public in namespace cpp
- Category
- C++
- Title
- if esle in c++
- Category
- C++
- Title
- c++ random
- Category
- C++
- Title
- cannot jump from switch statement to this case label c++
- Category
- C++
- Title
- c++ remove text file
- Category
- C++
- Title
- elseif c++
- Category
- C++
- Title
- c++ char print align
- Category
- C++
- Title
- c++ return multiple values
- Category
- C++
- Title
- error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(s[i] != "b"){
- Category
- C++
- Title
- c++ variable argument
- Category
- C++
- Title
- set mimetype validation in mongoose
- Category
- C++