determine if an integer value is odd or is even
Attention! 👉Starting November 2024, BlitzCoder.org will now be BlitzBasic.org.
Tweet blitz3d blitzbasic code-archives algorithms
for archive :
;determine if an integer value is odd or is even 20160101
Graphics3D(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()
Next
End()
Function IsOdd(TInt%)
R% = Abs(TInt) Mod 2
If(R = 0)
Return False
ElseIf(R = 1)
Return True
EndIf
End Function
Function IsEven(TInt%)
R% = Abs(TInt) Mod 2
If(R = 0)
Return True
ElseIf(R = 1)
Return False
EndIf
End Function
This is nice RemiD. btw should add it like as algorithm or miscellaneous tag to appear in code archive.
Edit: I already went ahead and updated your posts and added the corresponding category tags for each so it can be displayed on the code archvied index.
Thanks again, you are on a streak
Reply To Topic (minimum 10 characters)
Please log in to reply