# Thread: Need To generate the factorial of No Greater Than 10 In C

1. First Message. Here is a part of my program. You can calculate 10000!, maybe more.
I am cutting code.

#define Max_Digit 20000 // May be changed by memory
#define Base 10 // 256 is confortable
struct GreatNumber{
public:
int digits[Max_Digit];
int decflag;
int positionflag;
}stemp,sptemp,temp2;

GreatNumber Mult(GreatNumber X, GreatNumber Y)
//Spider-Multiplication of numbers By:Slayerchange
{
int log1=0,log2=0,log3=0,log4=0,artik=0,deger=0;
log2=Y.positionflag+1;
log4=X.positionflag+1;
NullNumber(sptemp);
NullNumber(temp2);
for(log1=0;log1&lt;=log2;log1++)
{
for(log3=0;log3&lt;=log4;log3++)
{
deger=Y.digits[log1]*X.digits[log3]+artik;
if(sptemp.digits[log1+log3]+deger&lt;Base){
sptemp.digits[log1+log3]+=deger;
artik=0;
deger=0;}
else{
deger+=sptemp.digits[log1+log3];
sptemp.digits[log1+log3]=deger%Base;
artik=(deger-deger%Base)/Base;
}
}
SetPosition(sptemp);
temp2=sum(temp2,sptemp);
NullNumber(sptemp);
}
return temp2;
}
//Some functions here irrevelent.You can delete them. Here is fakto.
void Fakto1000(void)
//1000!
{
GreatNumber A,B,C;
NullNumber(A);
NullNumber(B);
NullNumber(C);
A.digits[5]=1;
B.digits[0]=1;
C.digits[0]=1;
SetPosition(A);
SetPosition(B);
SetPosition(C);
do{
Inc(B,0,1);
C=Mult(C,B);
shownumber(B);
cout&lt;&lt;"\nFakto=";
shownumber(C);
}while(!Equal(A,B));
}

2. First Message. Here is a part of my program. You can calculate 10000!, maybe ore.
I am cutting code.
Ain't you cutting too much code? I can't see any definitions for SetPosition(), NullNumber() and shownumber(). Can you explain a bit about your code?

Peace always,
&lt;jdenny&gt;

3. Sorry ,
INC(A,x,y):
Increase A[x] by y
NullNumber:
for all x upto Max_Digit , let A[x]=0
SetPosition:
Numbers are added into A[x] from left to write. Return , number's digit.
shownumber:
cout A[x] up to positionflag.
Here is the full-testing program. mult2() function and some of them are for testing ,you can delete them all.

4. Please look this site. You will find lots of interesting program codes.

Page 3 of 3 First 123

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

×