Practice · 4 problems
Number Theory
0 of 4 solved on this device
- 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
- 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
- 162Count PrimesGiven an integer `n`, return the number of prime numbers strictly less than n.Medium
- 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