FastPrepFraction to Recurring Decimal
Problems/Fraction to Recurring Decimal

Fraction to Recurring Decimal

Airbnb logoAirbnb● MediumFULLTIMEINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The image in the report shows the fraction-to-recurring-decimal task for positive integers. We keep the same goal of writing the decimal exactly. We extended the input to signed 32-bit integers.

Our version is about 95% the same as the reported question.

Given two integers numerator and denominator, return their exact decimal representation as a string.

  • If the fractional part terminates, return it normally.
  • If part of the fractional digits repeats forever, enclose the repeating part in parentheses.
  • Include a leading minus sign exactly when the result is negative.

The result must not contain unnecessary leading zeros or a decimal point when the value is an integer.

Function

fractionToDecimal(numerator: int, denominator: int) → String

Examples

Example 1

numerator = 1denominator = 2return = "0.5"

The remainder becomes zero after one decimal digit.

Example 2

numerator = 2denominator = 3return = "0.(6)"

Remainder 2 repeats, so digit 6 is enclosed in parentheses.

Example 3

numerator = -50denominator = 8return = "-6.25"

The signs differ and the fractional part terminates.

Constraints

  • -2^31 <= numerator <= 2^31 - 1.
  • -2^31 <= denominator <= 2^31 - 1.
  • denominator != 0.

More Airbnb Online Assessment questions

  • In-Memory File SystemOA · Seen Nov 2026
  • Task Management SystemOA · Seen Nov 2026
  • Recipe Management SystemOA · Seen Nov 2026
  • Progressive Banking SystemOA · Seen Nov 2026
  • Credit Accounts with Scheduled TransfersOA · Seen Oct 2026
  • Parcel Attribute Store with TTLOA · Seen Oct 2026
  • Parcel Event TrackingOA · Seen Oct 2026
  • Median Home Price by CityOA · Seen Sep 2026
  • Worker Management (Promotion Track), Part 4: Full-Shift Double PayOA · Seen Sep 2026
  • Worker Management (Promotion Track), Part 3: Promotions and SalaryOA · Seen Sep 2026

Similar questions at other companies

  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Bouncing Square Reaches a Screen CornerDuolingo · OADuolingo interview questions
  • Arithmetic Triplets After QueriesCapital One · OACapital One interview questions
  • Fractional Share Inventory FlatteningRobinhood · PHONE SCREEN · ONSITE INTERVIEWRobinhood interview questions
  • Group-Relative Policy AdvantagesAmazon · ONSITE INTERVIEW
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
  • Stock System with Updates and Percentage ChangeLead Bank · ONSITE INTERVIEWLead Bank interview questions
  • Transaction Fee Calculator — Channel Volume TiersStripe · PHONE SCREENStripe interview questions
  • Pro-Rata Order BookIMC Trading · ONSITE INTERVIEWIMC Trading interview questions
  • Organization Reputation After Employee DeparturesHSBC · OAHSBC interview questions

Interview reports that mention this question

  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
  • Airbnb Intern OA, Halloween Candy: 22 Experiences (Part 3 of 7)
  • Airbnb Intern OA, Donut Challenge: 22 Experiences (Part 2 of 7)
  • Airbnb SWE Intern OA / Interviews: 122 Experiences (Part 1 of 7)

Airbnb interview experiences

  • Airbnb OA · November 2026
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public String fractionToDecimal(int numerator, int denominator) {
      // Write your code here.
    }
}
Checking account…