-
February 8th, 2004, 11:29 PM
#21
Junior Member
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<=log2;log1++)
{
for(log3=0;log3<=log4;log3++)
{
deger=Y.digits[log1]*X.digits[log3]+artik;
if(sptemp.digits[log1+log3]+deger<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<<"\nFakto=";
shownumber(C);
}while(!Equal(A,B));
}
-
February 9th, 2004, 08:20 AM
#22
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,
<jdenny>
Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds
-
February 9th, 2004, 01:02 PM
#23
Junior Member
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.
-
February 9th, 2004, 01:28 PM
#24
Junior Member
Please look this site. You will find lots of interesting program codes.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|