Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a function to check if a number is a happy number.

Hard

Problem 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") } }
Log in or sign up to run or submit your code.Log inSign up
Input
A hardcoded number, e.g., 19.
Expected Output
19 is a happy number