Hello good people of YA programming section I really need some help here, I made a function to find me the multiplication of the factorial of any number that I input but if I put say 100 it only gives back 0, when it should give 5050, maybe its the size of the ints but ints cant take like 2 Billion something, I dont know if anyone notices anything:

#include <stdlib.h>
#include <iostream>
using namespace std;
int fakt(int n);
int faktM(int n1);
int main(){
int factoriel, m, factoriel2;

cout<<"Enter Number: "<<endl;
factoriel = fakt(m);
factoriel2 = faktM(m);
return 0;

int fakt(int n){
int c, fact;
c = n;
while (c > 0){
cout<<" "<<c<<endl;

return c;

int faktM(int n1){
int fact = 1;
int i;

for(i = 1; i <= n1; ++i){
fact *= i;

cout<<"multiplication: "<<fact<<endl;
return fact;



Recommended Answers

All 2 Replies

The factorial of 100 is 9.332621544e157 so you are getting an overflow. Try 5! And see what you get.

Format your code so it can be read and followed easily by others.

You calculated the values in the functions but never returned them.

[edit]Sorry, your formatting caused me to misread the code. See?[/edit]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.