Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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

  • Last Updated : 21 Apr, 2020

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
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!