Sign in to follow this  
Followers 0
seargent master

is the number odd or even

4 posts in this topic

#1 ·  Posted (edited)

: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')
Else
   MsgBox(0,'','Could not parse $I_Result')
EndIf

odd_or_even_real_1.au3

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
        SetError(1)
        Return -1
    EndIf
    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)

EndFunc

<{POST_SNAPBACK}>

:-) And...

Func Even($n)

Return Not BitAnd($n, 1)

EndFunc

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  
Followers 0