Open In App

Checking if a number is odd in Julia – isodd() Method

Last Updated : 21 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The isodd() is an inbuilt function in julia which is used to return true if the specified value x is odd i.e, not divisible by 2 else returns false.

Syntax: isodd(x::Integer)

Parameters:

  • x: Specified number

Returns: It returns true if the specified value x is odd i.e, not divisible by 2 else returns false.

Example 1:




# Julia program to illustrate 
# the use of isodd() method
  
# Getting true for the odd
# value else returns false
println(isodd(0))
println(isodd(1))
println(isodd(-2))


Output:

false
true
false

Example 2:




# Julia program to illustrate 
# the use of isodd() method
  
# Getting true for the odd
# value else returns false
println(isodd(6))
println(isodd(7))
println(isodd(-10))
println(isodd(-11))


Output:

false
true
false
true

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads