Jump to content
Sign in to follow this  
seargent master

is the number odd or even

Recommended Posts

seargent master

:whistle: i dont know how this can be helpful but..... here it is

#include <math.au3>
$I_Var = InputBox('Odd or Even', 'Enter a number:')
$I_Result = _MathCheckDiv($I_Var, 2)
If $I_Result = -1 Or @error = 1 Then
   MsgBox(0,'','You did not enter a valid number')
ElseIf $I_Result = 1 Then
   MsgBox(0,'','Number is odd')
ElseIf $I_Result = 2 Then
   MsgBox(0,'','Number is even')
   MsgBox(0,'','Could not parse $I_Result')


Edited by seargent master

Share this post

Link to post
Share on other sites

try to make it into a func :whistle:

IIRC it has been done before. but dont let that ruin you fun.

i made this a long time ago also:

Func _IsEven($i_Check)
    If StringIsDigit($i_Check) Then $i_Check = Number($i_Check)
    If Not IsNumber($i_Check) Then
        Return -1
    If Not IsInt($i_Check) Then Return 0
    If IsInt($i_Check / 2) Then Return 1
    Return 0
EndFunc;==> _IsEven()

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post

Link to post
Share on other sites

;Without any error checking whatsoever

Func _IsEven($n)

  Return Not Mod($n, 2)



:-) And...

Func Even($n)

Return Not BitAnd($n, 1)


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.