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

Programming Exercises

Find the GCD of two numbers

Easy

Problem Statement

Find the GCD of two numbers

Sample Input

a = 12, b = 15

Sample Output

The GCD of 12 and 15 is: 3

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun gcd(a: Int, b: Int): Int { // Add your code here to calculate the GCD } fun main() { val a = 12 val b = 15 println("The GCD of $a and $b is: ${gcd(a, b)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
a = 12, b = 15
Expected Output
The GCD of 12 and 15 is: 3