Hello I am new to Rexx and working on creating the luhn algorithm in a subroutine get an the error when trying to add the digit to the variable to hold the sum in each iteration of my loop. The code runs with no error when I remove 'sumOfNum = sumOfNum + numToSum' statement.
inspecting 7459274623941467 108 +++ sumOfNum = sumOfNum + numToSum 41 +++ call INSPECT IRX0041I Error running CCVIEW, line 108: Bad arithmetic conversion READY
INSPECT:
say 'inspecting' cc_digits
up = 1
flag = 0 /* for every other digit */
/* Loop to assess each digit in cc_digits */
do i = 0 to 16 by 1
/* Identify Numbers to sum */
digit = SUBSTR(cc_digits,up,1) /* Returns digit */
up = up + 1 /* for next digit */
/* to use only every other number */
if (if flag = 0) then
do
numToSum = 0
numToSum = digit * 2
flag = 1
end
/* Skip this digit */
else
do
Flag = 0
end
/*if digit > 9 sum digits of digit */
if (numToSum > 9) then
do
digit1 = SUBSTR(cc_digits,1,1)
digit2 = SUBSTR(cc_digits,2,1)
numToSum = digit1 + digit2
end
/* to accumulate sum */
sumOfNum = sumOfNum + numToSum
end
RETURN