I was writing a program to factorize a number given, with the goal being computing the maximum factorial that will fit in an unsigned long long
data type.
That's the code. With it i can factorize numbers up to 65.
#include <iostream>
#include <libcork/core.h>
using namespace std;
int main()
{
unsigned long long numero;
unsigned long long factorial=1;
cout << "inserisci numero da fattorizzare ---> ";
cin >> numero;
cout <<"\n";
for (unsigned long long i=1; i <= numero; i++)
{
factorial = factorial*i;
}
cout << factorial;
}
But while i was writing it, i thought, "couldn't i make the maximum number bigger by converting the result to a power of 10?"
The question makes sense to me, but i do not know how to apply the concept in c++
Thanks in advance :)
Aucun commentaire:
Enregistrer un commentaire