Opencl arbitary precision and calculating factorial
I have a problem calculating a "big" factorial. The big problem is, that I can't write into a ulong16 vector. Here you can download my code:
The algorithm is easy:
Get the primes from 3 to n, then calculate their exponents using this equation:
exponent(p)=floor(n,p)+floor(n,p^2)+...... while the parts of this sum greater than 1 and so on. (This algorithm is made by Crandall, you can find the algorhitm in his book) .
The main problem is I couldn't write into n_factor ( named ulong16 Product in the kernel).
I think the problem is not big, but I'm a bit tired and I can't find it.
Thanks in advance,
Re: Opencl arbitary precision and calculating factorial
I figured it out. I had to cast the values of primes and shift the gid e.g.:
primes[sgid] -> (long long unsigned int) primes[sgid];