Skip to content

Instantly share code, notes, and snippets.

@Sedose
Created September 7, 2024 08:10
Show Gist options
  • Save Sedose/1022d5f5e2c5b84066d3a037454d7c87 to your computer and use it in GitHub Desktop.
Save Sedose/1022d5f5e2c5b84066d3a037454d7c87 to your computer and use it in GitHub Desktop.
@main def main(): Unit =
println(isUgly(14))
private val primes = List(2, 3, 5)
def isUgly(n: Int): Boolean =
var result = n
for (prime <- primes)
while (result > 1 && result % prime == 0)
result /= prime
result == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment