## Kotlin Program:

- To check number is in binary or not

#### Example:

User Input: 11111

Output: Number is in binary form

``````import java.util.Scanner

fun binary(num:Int):Boolean {
var n=num
while(n!=0) {
if(n%10==0 || n%10==1)
n/=10
else return false
}
return true
}

fun main(args: Array<String>) {

val userInput = Scanner(System.`in`)
var num:Int = userInput.nextInt()

if(binary(num))
println("Number is in binary form")
else
println("Number is not in binary form")
}``````

### Output:

```  Enter Your number : 1101
Number is in binary form
```
Program
number

Binary Numbers : Numbers with only 0 & 1 combination

`Examples like: 101, 111, 10, 11111`

Main Logic :

``````fun binary(num:Int):Boolean {
var n=num
while(n!=0) {
if(n%10==0 || n%10==1)
n/=10
else return false
}
return true
}``````

Divide the number by 10 while your number becomes 0[ZERO] &
In-between check, is there any remainder other than 0 & 1

Concept

Coming Soon !

Quick
Tutorial

# Quote

The best preparation for good work tomorrow is to do good work today.