isodd()
是 julia 中的一个内置函数,用于在指定值x为奇数时返回 true,即不能被 2 整除,否则返回 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.
示例 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))
输出:
false
true
false
示例 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))
输出:
false
true
false
true