Create a function to check if a number is a happy number.
HardProblem Statement
Create a function to check if a number is a happy number.
Sample Input
A hardcoded number, e.g., 19.
Sample Output
19 is a happy number
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun isHappyNumber(num: Int): Boolean {
// Add your code here to check if the number is happy
}
fun main() {
val num = 19
if (isHappyNumber(num)) {
println("$num is a happy number")
} else {
println("$num is not a happy number")
}
}
Input
A hardcoded number, e.g., 19.
Expected Output
19 is a happy number