## COBOL logic to find Multiples of a value

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

### COBOL logic to find Multiples of a value

Hi,

My requirement is to check whether the input data is in multiples of another input field, if it so, then i need to set an indicatior to "YES", else it is "NO" .

Example: If input data (50) is in multiples of quantity field (5) , then i need to set indicator to yes.

Input DATA =50,
Quantity = 5
then Indicator to be set to YES.

Can someone help me with the logic to build this.
luckyboyroh

Posts: 35
Joined: Wed Jan 16, 2013 4:05 pm
Has thanked: 3 times
Been thanked: 0 time

### Re: COBOL logic to find Multiples of a value

Hi,

You need to divide input data by quantity and check if the remainder is equal zero, then you set the indicator to YES.
http://publib.boulder.ibm.com/infocente ... 4ls109.htm
tivrfoa

Posts: 77
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 56 times
Been thanked: 0 time

### Re: COBOL logic to find Multiples of a value

where do You face problems
the logic or the code ???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator

Posts: 2489
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 119 times

### Re: COBOL logic to find Multiples of a value

If you put an 88 on the field you define for the remainder, you can make it much clearer. Indeed, unless requiring storing on a file, you could just use the 88 for your YES/NO in a "logical" sense.

If you are doing "a lot" (many millions) of these, then note that with some divisors you can tell by looking at the last 1-3 digits whether or not it is "exact".

These users thanked the author BillyBoyo for the post:
tivrfoa (Wed Jan 16, 2013 6:32 pm)
BillyBoyo
Global moderator

Posts: 3732
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 253 times

### Re: COBOL logic to find Multiples of a value

Thanks all for ur suggestions. It worked.
luckyboyroh

Posts: 35
Joined: Wed Jan 16, 2013 4:05 pm
Has thanked: 3 times
Been thanked: 0 time