Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Checking if a number is even in Julia – iseven() Method

  • Last Updated : 21 Apr, 2020

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

Syntax: iseven(x::Integer)

Parameters:

  • x: Specified number

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

Example 1:






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

Output:

true
false
true

Example 2:




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

Output:

true
false
true
false
My Personal Notes arrow_drop_up
Recommended Articles
Page :