FastPrepOdd First-Success Roll Probability
Problems/Odd First-Success Roll Probability

Odd First-Success Roll Probability

IMC Trading logoIMC Trading● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IMC Trading new grad phone screen. The reported oral question uses a six-sided die. It asks about the odd total number of rolls until the first 6. Our goal is about 95% the same. We chose these things: fair rolls that do not affect each other, a number of sides you can change, limits, and the output precision. The report did not ask for code.

You roll a fair die with faces numbered 1 through sides. Every face is equally likely, and each roll is independent of the others. Keep rolling until the die first shows the face sides.

Let N be the total number of rolls. Count from 1, and include the roll that showed sides. Return the probability that N is odd.

The classic version of this question uses a six-sided die and waits for the first 6. Here sides is an input, so the die size can change. Complete oddFirstSuccessProbability(sides). It returns a double. Do not round it.

Your answer is accepted when abs(actual-expected) <= 1e-9 * max(1,abs(expected)).

Function

oddFirstSuccessProbability(sides: int) → double

Examples

Example 1

sides = 6return = 0.5454545454545454

The exact probability is 6/11.

Example 2

sides = 2return = 0.6666666666666666

The exact probability is 2/3.

Example 3

sides = 3return = 0.6

The exact probability is 3/5.

Constraints

  • 2 <= sides <= 10^6
  • The die is fair, and the rolls are independent.
  • The count of rolls includes the roll that shows sides.

More IMC Trading Phone Screen questions

  • Election District Budget Allocation AnalysisPHONE SCREEN · Seen Aug 2026
  • Uniform Variables: Smaller Below Larger SquaredPHONE SCREEN · Seen Mar 2026
  • Combination Sum with Unlimited ReusePHONE SCREEN · Seen Dec 2025
  • Valid Range of a Three-Outcome Probability ParameterPHONE SCREEN · Seen Dec 2025
  • Expected Fishing CatchPHONE SCREEN · Seen Dec 2025
  • Count Routes Through a City GridPHONE SCREEN · Seen Nov 2024
  • Expected City Arrival and Return DaysPHONE SCREEN · Seen Nov 2024
  • Stationary City Population SharesPHONE SCREEN · Seen Nov 2024
  • Maximum Falling Path SumPHONE SCREEN · Seen Nov 2024
  • Trading Profit Percentage ChangePHONE SCREEN · Seen Feb 2024

Similar questions at other companies

  • Parking Fee CalculatorBreeze · PHONE SCREEN
  • Merchant Payout Reserve CalculatorStripe · PHONE SCREENStripe interview questions
  • Sqrt(x)LinkedIn · PHONE SCREENLinkedIn interview questions
  • Automation Pipeline, Part 1: Single WorkerPlaid · PHONE SCREENPlaid interview questions
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
  • Circular Primes Below a LimitAmazon · PHONE SCREEN
  • Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
  • Streaming AverageXantium · PHONE SCREEN
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
  • Stack Formula InterpreterTypeSafe AI · PHONE SCREEN

IMC Trading interview experiences

  • IMC Trading OA: What It Tests (2026)
  • 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)
All IMC Trading interview questionsSee IMC Trading hiring insights
Saved
class Solution {
    public double oddFirstSuccessProbability(int sides) {
        // Write your solution here.
    }
}
Checking account…