# odd or even number ?

## Recommended Posts

hello,

need help with logic to understand when a number is odd or even.

When i understand if number is odd i must add 1 to solve a little problem i've in another script.

m.

##### Share on other sites

hello,

need help with logic to understand when a number is odd or even.

When i understand if number is odd i must add 1 to solve a little problem i've in another script.

m.

```\$n = 18
If mod(\$n, 2) = 0 Then
MsgBox(0,"", \$n & " is an even number.")
Else
MsgBox(0, "", \$n & " is an odd number.")
EndIf

\$x = mod(4, 7)  ;\$x == 4 because the divisor > dividend

\$y = mod(1, 3/4)  ;\$y == 0.25 because the divisor is a float
\$n = 18
If mod(\$n, 2) = 0 Then
MsgBox(0,"", \$n & " is an even number.")
Else
MsgBox(0, "", \$n & " is an odd number.")
EndIf

\$x = mod(4, 7)  ;\$x == 4 because the divisor > dividend

\$y = mod(1, 3/4)  ;\$y == 0.25 because the divisor is a float```

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace \$ghGDIPDll with \$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

wow, fast as lighting,

find also this:

```\$number = 123

If Not BitAND(\$number,1) Then
MsgBox(0,"","even number")
Else
MsgBox(0,"","odd number")
EndIf```

thank you again,

m.

##### Share on other sites

```\$n = 17
\$n += (mod(\$n,2))
MsgBox(0,"", \$n)```

## Create an account

Register a new account