- May

- 13,073

- 178

Code:

`TCC: V:\number.btm [18] Syntax error "10*n+g"`

News flash! ... It works if,

**in that line only**, I use "%n" instead of "n" (and it arrives at the right answer).

I don't get it. This must be a very obscure bug (or I'm missing something utterly obvious).

Code:

```
set count=0
do a=1 to 9 by 2
do b=2 to 8 by 2
do c=1 to 9 by 2
do d=2 to 8 by 2
do f=2 to 8 by 2
do g=1 to 9 by 2
do h=2 to 8 by 2
do i=1 to 9 by 2
set /a count+=1
set bcontinue=0
set /a n=100*a+10*b+c
if %@eval[n MOD 3] NE 0 iterate
set /a n=10*n+d
if %@eval[n MOD 4] NE 0 iterate
set /a n=100*n+50+f
if %@eval[n MOD 6] NE 0 iterate
set /a n=10*n+g & REM <===================== this line
if %@eval[n MOD 7] NE 0 iterate
set /a n=10*n+h
if %@eval[n MOD 8] NE 0 iterate
set /a n=10*n+i
if %@eval[n MOD 9] NE 0 iterate
do z=1 to 9
if %@index[%n,%z] == -1 (set bcontinue=1 & leave)
enddo
if %bcontinue == 1 iterate
echo %n
enddo
enddo
enddo
enddo
enddo
enddo
enddo
enddo
```

The question: Find a 9-digit number which uses each of 1, 2, ..., 9 exactly once, and has the property that, for i=1 to 9, the number comprising its left-hand i digits is divisible by i. The answer is unique.