// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)

Project Euler Solutions

Project Euler 288 Solution

Project Euler 288 Solution

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.
download arrowUse this link to get the Project Euler 288 Solution Python 2.7 source.


  • 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


3 Responses to “Project Euler 288 Solution”

  1. 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?

    Posted by Max Headroom | October 23, 2015, 3:47 PM
    • 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.

      Posted by Martina Kolova | October 25, 2015, 8:36 PM
  2. Why “[…] if N < n […]" ???

    Posted by Max Headroom | October 23, 2015, 3:40 PM

Post a comment