Kotlin Program to Convert Binary Number to Octal and vice-versa In this program, you’ll learn to convert binary number to a octal number and vice-versa using functions in Kotlin. Example 1: Program to Convert Binary to Octal In this program, we will first convert binary number to decimal. Then, the decimal number is converted to octal. …

# Month: May 2021

Kotlin Program to Convert Octal Number to Decimal and vice-versa In this program, you’ll learn to convert octal number to a decimal number and vice-versa using functions in Kotlin. Example 1: Program to Convert Decimal to Octal fun main(args: Array<String>) { val decimal = 78 val octal = convertDecimalToOctal(decimal) println(“$decimal in decimal = $octal in …

Kotlin Program to Find G.C.D Using Recursion In this program, you’ll learn to find the GCD (Greatest Common Divisor) or HCF using a recursive function in Kotlin. This program takes two positive integers and calculates GCD using recursion. Example: GCD of Two Numbers using Recursion fun main(args: Array<String>) { val n1 = 366 val n2 = …

Kotlin Program to Find the Sum of Natural Numbers using Recursion In this program, you’ll learn to find the sum of natural number using recursion in Kotlin. This is done with the help of a recursive function. The positive numbers 1, 2, 3… are known as natural numbers. The program below takes a positive integer …

Kotlin Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers In this program, you’ll learn to check whether a given number can be expressed as a sum of two prime numbers or not. This is done with the help of loops and break statements in Kotlin. To accomplish this …

Kotlin Program to Display Factors of a Number In this program, you’ll learn to display all factors of a given number using for loop in Kotlin. Example: Factors of a Positive Integer fun main(args: Array<String>) { val number = 60 print(“Factors of $number are: “) for (i in 1..number) { if (number % i == …

Kotlin Program to Display Armstrong Numbers Between Intervals Using Function In this program, you’ll learn to display all armstrong numbers between two given intervals, low and high, using a function in Kotlin. To find all armstrong numbers between two integers, checkArmstrong() function is created. Example: Armstrong Numbers Between Two Integers fun main(args: Array<String>) { val low …

Kotlin Program to Display Prime Numbers Between Intervals Using Function In this program, you’ll learn to display all prime numbers between the given intervals using a function in Kotlin. To find all prime numbers between two integers, checkPrimeNumber() function is created. Example: Prime Numbers Between Two Integers fun main(args: Array<String>) { var low = 20 …

Kotlin Program to Display Armstrong Number Between Two Intervals In this program, you’ll learn to display all armstrong numbers between two given intervals, low and high, in Kotlin. A positive integer is called an Armstrong number of order n if abcd… = an + bn + cn + dn + … In case of an Armstrong number …

Kotlin Program to Check Armstrong Number In this program, you’ll learn to check whether a given number is armstrong number or not. You’ll learn to do this by using a while loop in Kotlin. A positive integer is called an Armstrong number of order n if abcd… = an + bn + cn + dn + … …