FastPrepUgly Number
Problems/Ugly Number

Ugly Number

SambaNova Systems logoSambaNova Systems● EasyNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand SambaNova runtime-team new-grad interview report dated April 2, 2021 names Ugly Number as the coding question and asks for an optimized solution. Our version is about 100% the same as the reported question.

Return whether n is a positive integer whose prime factors are limited to 2, 3, and 5. The number 1 is ugly because it has no prime factors.

Function

isUgly(n: int) → boolean

Examples

Example 1

n = 6return = true

6 equals 2 times 3.

Example 2

n = 1return = true

One has no prime factors.

Example 3

n = 14return = false

The factor 7 is forbidden.

Constraints

  • -2^31 <= n <= 2^31 - 1.

More SambaNova Systems Onsite Interview questions

  • Vectorized K-Means AssignmentsONSITE INTERVIEW · Seen Apr 2024
  • 4Sum II Tuple CountONSITE INTERVIEW · Seen Jun 2022
  • Bomb Enemy Best CoordinatesONSITE INTERVIEW · Seen Jun 2022
  • Sum Nodes with an Even-Valued GrandparentONSITE INTERVIEW · Seen Jun 2022
  • Validate Binary Search TreeONSITE INTERVIEW · Seen Jun 2022
  • Deterministic Zigzag SortPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Maximum Area of IslandONSITE INTERVIEW · Seen Jun 2022
  • Task Scheduler with CooldownPHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Point Inside a TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2022
  • Parse Variable, Expression, and Application TreesPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022

Similar questions at other companies

  • Confusing Bib NumbersVerily · ONSITE INTERVIEW
  • 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
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Circular Primes Below a LimitAmazon · PHONE SCREEN
  • Palindrome NumberKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
  • Streaming AverageXantium · PHONE SCREEN
  • Plus OneDruva · ONSITE INTERVIEW
  • Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
All SambaNova Systems interview questionsSee SambaNova Systems hiring insights
Saved
class Solution {
    public boolean isUgly(int n) {
        // write your code here
    }
}
Checking account…