;determine if an integer value is odd or is even 20160101Graphics3D(640,480,32,2)SeedRnd(MilliSecs())For i% = 0 To 101 R1% = IsOdd(i) R2% = IsEven(i) DebugLog("i = "+i) DebugLog("IsOdd ? "+R1) DebugLog("IsEven ? "+R2) WaitKey()NextEnd()Function IsOdd(TInt%) R% = Abs(TInt) Mod 2 If(R = 0) Return False ElseIf(R = 1) Return True EndIfEnd FunctionFunction IsEven(TInt%) R% = Abs(TInt) Mod 2 If(R = 0) Return True ElseIf(R = 1) Return False EndIfEnd Function

Function IsOdd(TInt%) R% = Abs(TInt) Mod 2 If(R = 0) Return False Endif Return TrueEnd Function

Function IsEven( I% ) Return ( Abs(I) Mod 2 ) = 0End Function

If( Not IsEven( num ) ) ; odd number

If number & 1 Number is oddElse Number is even

Function IsOdd(num%) Return (num & 1)End Function

Function IsEven(num%) Return Not (num & 1)End Function

Function isEven(num%) If num Shr 1 Shl 1 = num Then Return True Return FalseEnd FunctionFunction isOdd(num%) If num Shr 1 Shl 1 <> num Then Return True Return FalseEnd FunctionFor i = 0 To 100 If isEven(i) Print i+" is even" ElseIf isOdd(i) Print i+" is odd" Else Print i+" is nothing" EndIfNext

Function isEven(num%) If ((num - 1) Xor num) <> 1 Then Return True Return FalseEnd FunctionFunction isOdd(num%) If ((num - 1) Xor num) = 1 Then Return True Return FalseEnd Function

Function isEven(num%) For i = -2147483648 To +2147483647 Step 2 If num = i Then Return True Next Return FalseEnd FunctionFunction isOdd(num%) For i = -2147483647 To +2147483647 Step 2 If num = i Then Return True Next Return FalseEnd Function

Code: [Select]Function isEven(num%) For i = -2147483648 To +2147483647 Step 2 If num = i Then Return True Next Return FalseEnd FunctionFunction isOdd(num%) For i = -2147483647 To +2147483647 Step 2 If num = i Then Return True Next Return FalseEnd Function