FastPrepCount Numbers with a Prime Digit Sum
Problems/Count Numbers with a Prime Digit Sum

Count Numbers with a Prime Digit Sum

Rippling logoRippling● HardINTERNFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The digit-sum condition and inclusive range limit match the source at about 98%.

The strings lower and upper give positive integers L and R in decimal, with no leading zeros. Count the integers x in the inclusive interval [L, R] whose decimal digit sum is prime.

A prime is an integer greater than one with exactly two positive divisors. Return the exact count as a decimal string with no leading zeros, except for "0" when the count is zero.

Function

countPrimeDigitSums(lower: String, upper: String) → String

Examples

Example 1

lower = "1"upper = "20"return = "9"

The qualifying numbers are 2, 3, 5, 7, 11, 12, 14, 16, and 20.

Example 2

lower = "98"upper = "102"return = "3"

The qualifying numbers are 98, 101, and 102, with digit sums 17, 2, and 3.

Constraints

  • 1 <= L <= R <= 10^18.
  • Input strings contain only decimal digits and have no leading zeros.
  • Use exact integer arithmetic; no modulo is applied.

More Rippling Online Assessment questions

  • Most Segments That Sort the ArrayOA · Seen Nov 2026
  • Palindromic Paths to the RootOA · Seen Nov 2026
  • Server InvestmentOA · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • REST API: Highest International StudentsOA · Seen Sep 2026
  • Token ValidationOA · Seen Sep 2026
  • Consistent LogsOA · Seen Sep 2026
  • Costliest ChocolateOA · Seen Sep 2026
  • Server ManagementOA · Seen Sep 2026
  • Cyber Beacon DetectionOA · Seen Aug 2026

Similar questions at other companies

  • At Most K Jumps with Quadratic Transition CostInfosys · OAInfosys interview questions
  • Maximum Signal Walk in a Server TreeTower Research Capital · OA
  • Count Nondecreasing Digit-Sum ArraysMicrosoft · OAMicrosoft interview questions
  • Jump Game with Prime-3 StepsUber · OAUber interview questions
  • Profitable Currency Exchange CycleOptiver · OAOptiver interview questions
  • Match an XOR-Adjusted SumSquarepoint Capital · OASquarepoint Capital interview questions
  • Count Permutations Without Three Equal Parities in a RowGoogle · OAGoogle interview questions
  • TikTok UserTikTok · OATikTok interview questions
  • String Transformation (Also for Infra Automation Intern)Snowflake · OASnowflake interview questions
  • Digit SumBank of New York Mellon · OA

Interview reports that mention this question

  • Rippling Intern Interview History: 17 Experiences (Part 5 of 5)

Rippling interview experiences

  • Rippling Senior SWE Full Loop Questions: 1 Experience
  • Rippling Experienced SWE Phone Screens: 2 Experiences
  • Rippling Design Rounds and Onsites: 17 Experiences (Part 3 of 3)
  • Rippling Phone Coding Screens: 14 Experiences (Part 2 of 3)
  • Rippling SWE Screens and Loops: 31 Experiences (Part 1 of 3)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public String countPrimeDigitSums(String lower, String upper) {
        // write your code here
    }
}
Checking account…