Project Euler 288: An enormous factorial
Problem Description
For any prime p the number N(p,q) is defined by
N(p,q) = ∑n=0 to q Tn*pn
with Tn generated by the following random number generator:
S0 = 290797
Sn+1 = Sn2 mod 50515093
Tn = Sn mod p
Let Nfac(p,q) be the factorial of N(p,q).
Let NF(p,q) be the number of factors p in Nfac(p,q).
You are given that NF(3,10000) mod 320=624955285.
Find NF(61,107) mod 6110
Project Euler 288 Solution
Runs < 5 seconds in Python 2.7.Use this link to get the Project Euler 288 Solution Python 2.7 source.
Afterthoughts
- The Trinket above will run the problem’s smaller example in a few seconds. The larger problem would take the Trinket too long to run.
Project Euler 288 Solution last updated
In addition to my previous comment…
I can’t seem to gather why there’s “z” for N < n and p**n… for the rest. Could anybody enlighten me?
This program could be cleaned up a bit to make it easier to understand.
The intention is to use z as often as required to prevent the expensive calculation as doing so would slow down the program considerably.
So, since the answer is mod 6110 we only need to calculate 610+611+612+…+619 then use precalculated z for the rest.
Why “[…] if N < n […]" ???