View Single Post
Old 2008-12-15, 14:05   #7
Syd's Avatar
Sep 2008
Krefeld, Germany

111001102 Posts

I'm finally done with it, it was a hell of work! A lot more than i thought it would be.
The first difficult part was the scanner/parser, it has to modify the expressions used and notice if they are actually the same, take care of operator priority and so on. There is still one bug in it, x^y^z is taken as (x^y)^z, not x^(y^z) and maybe some i didnt notice.

Next comes the tricky part: Special numbers can have factors that are special numbers, too. If a factor is submitted, all numbers above also have this factor, numers below it also may have this factor. I simplified this a little bit by using 3 tables:
factor <factorid, shortform, Maybe longform, digits, type enum(prime, prp, composite, unknown_too_big)>
hasfactor <factorid, factorid>
cofactor <factorid, factorid>

hasfactor contains all factors of a factor which are prime or where no factors are known, if a factor has been factorized, it moves to cofactor.
If a factor is submitted, it looks up recursively and adds the factor to every number found, modifies its type, next it goes down recursively and checks which numbers divide it.
If you give it a try, i'd be happy to read some comments
Syd is offline   Reply With Quote