FastPrepSum the Next Two Prime-Product Terms
Problems/Sum the Next Two Prime-Product Terms

Sum the Next Two Prime-Product Terms

IMC Trading logoIMC Trading● EasyNEW GRADOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported prefix and sum-of-two objective match at about 90%. The recurrence is a stated practice assumption supported by a reader explanation; the source authors did not confirm an answer. Pair counts beyond six are practice inputs.

A sequence begins 2, 5, 6, 11, 30, 37, 210, 221, 2310, 2323, 30030, 30047, ....

For this exercise, assume p[j] is the jth prime number, starting with p[1] = 2, and P[j] is the product of the first j primes. Pair j contains the two consecutive terms P[j] and P[j] + p[j+1].

You are given completedPairs, the number of complete pairs already present. Return the sum of the next two terms, which together form pair completedPairs + 1.

For this exercise, assume the pair count generalizes the six complete pairs displayed above. Complete sumNextPrimorialPair(completedPairs) and return the exact sum as a signed 64-bit integer.

Function

sumNextPrimorialPair(completedPairs: int) → long

Examples

Example 1

completedPairs = 6return = 1021039

The first six complete pairs end with (30030, 30047). The next prime product is 30030 * 17 = 510510, and its partner is 510510 + 19 = 510529. Their sum is 1021039.

Example 2

completedPairs = 1return = 17

The first pair is (2, 5). The next pair is (2 * 3, 2 * 3 + 5) = (6, 11), so the sum is 17.

Example 3

completedPairs = 14return = 1229779565176982873

The next pair uses the product of the first 15 primes, 614889782588491410, and the following prime, 53. Its two terms sum to 1229779565176982873. Exact 64-bit arithmetic is required.

Constraints

  • For this exercise, assume 1 <= completedPairs <= 14.
  • Pairs are numbered from 1 and use consecutive primes in increasing order.
  • The largest possible sum is 1229779565176982873, which fits a signed 64-bit integer.

More IMC Trading Online Assessment questions

  • Earliest Meeting Start on a 24-Hour ClockOA · Seen Nov 2026
  • Grid Paths with Override PassesOA · Seen Oct 2026
  • Weighted LFU CacheOA · Seen Sep 2026
  • Rock JumpingOA · Seen Aug 2026
  • Stack Batch RemovalOA · Seen Aug 2026
  • Chain of CommandOA · Seen Aug 2026
  • Choose ContainersOA · Seen Aug 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Sub-matrix SumsOA · Seen Jul 2026
  • Can Every Package Fit in a BoxOA · Seen Jul 2026

Similar questions at other companies

  • Summarize Taxi Drivers and RidesBoston Consulting Group · OA
  • Total Cost Against the Lowest Earlier PricePayPal · OA
  • Count Valid Square PairsAuxoAI · OA
  • Counting Cows by Their LegsSusquehanna International Group (SIG) · OA
  • Server InvestmentRippling · OA
  • Basic Item DiscountsPalantir · OA
  • Identification Number Check DigitAbridge · OA
  • Count Substrings With Identical CharactersVirtu Financial · OA
  • Next Pascal Row CoefficientIntuit · OA
  • Digit-Sum Sequence Join PointOpenAI · OA

Interview reports that mention this question

  • IMC Trading OA: What It Tests (2026)

IMC Trading interview experiences

  • IMC Trading SWE OA and Video: 18 Experiences (Part 3 of 3)
  • IMC Trading SWE OA Questions: 22 Experiences (Part 2 of 3)
  • IMC SWE New Grad OA and Interviews: 58 Experiences (Part 1 of 3)
See IMC Trading hiring insights
Saved
class Solution {
    public long sumNextPrimorialPair(int completedPairs) {
        // Write your solution here.
    }
}
Checking account…