Skip to content
Optimal Lab

Practice · 4 problems

Number Theory

0 of 4 solved on this device

Read the explainer · optimal-roundWhen to use it, and its look-alikes ↗
  1. 160Happy NumberA happy number is defined by repeatedly replacing the number with the sum of the squares of its digits; it is happy if this reaches 1. Given `n`, return true if it is happy.Easy
  2. 161Sqrt(x)Given a non-negative integer `x`, return the square root of x rounded DOWN to the nearest integer. You may not use any built-in exponent or square root function.Easy
  3. 162Count PrimesGiven an integer `n`, return the number of prime numbers strictly less than n.Medium
  4. 163Ugly Number IIAn ugly number has no prime factors other than 2, 3 and 5. Given an integer `n`, return the nth ugly number (1-indexed). By convention 1 is ugly.Medium