EVEN AND ODD NUMBER PROGRAMMING
EVEN AND ODD NUMBER PROGRAMMING
(OP)
I'm trying to program a line where I have a number and when this number is a even or odd number, the program changes. I'm looking for the fonction that will allow the program to change the pattern if x=2, 4, 6, 8, 10..... and will allow to change it again if x=1, 3, 5, 7, 9......
Like, I have
IF x 'fonction for even number'
pattern_1=2
else
pattern_1=3
endif
thanks
Like, I have
IF x 'fonction for even number'
pattern_1=2
else
pattern_1=3
endif
thanks





RE: EVEN AND ODD NUMBER PROGRAMMING
Integer division is division in which the fractional part (remainder) is discarded is called integer division and is sometimes denoted "\". Integer division can be defined as , where "/" denotes normal division and is the floor function. For example,
10 / 3 = 3 + .33333
so
10 \ 3 = 3
Then you must compare the two statements like this
if (10/3)-(10\3) <> 0
then
.....
else
.....
endif
Unfortunately, ProE does not have the "integer division" implemented, but you can simulate it using "floor" function:
if (10/3)-floor(10/3) <> 0 .....
-Hora
RE: EVEN AND ODD NUMBER PROGRAMMING
I have a pattern of prt0001 and a pattern of prt0002 and I want that when the pattern of prt0001 is a even number that the pattern of prt0002 is equal to the pattern of prt0001 divided by 2 but when the pattern of prt0001 is a odd number, I want the pattern of prt0002 to be equal to the pattern of prt0001 divided by 2 + 1
IF PATTERN_PRT0001=EVEN NUMBER
PATTERN_PRT0002=PATTERN_PRT0001/2
ELSE
IF PATTERN_PRT0001=ODD NUMBER
PATTERN_PRT0002=(PATTERN_PRT0001/2)+1
ENDIF
ENDIF
THANKS
RE: EVEN AND ODD NUMBER PROGRAMMING
if ((-1)^PATTERN_PRT0001 == 1)
then
.....
else
....
endif
because:
(-1)^even number = +1 and (-1)^odd number = -1
That's all. Good luck
-Hora