' npr.bas - tct - 1/13/2010 PRINT "npr.bas - tct - 1/13/2010": PRINT PRINT "see http://primepuzzle.com/tc/npr.html": PRINT OPEN "o", 1, "npr.out" FOR year = 1 TO 5000 noth = 2 10 ' w = noth MOD 10 + 1 ' if noth = 23, maxin starts off at 4 maxin = w WHILE w < 6 w = w + 1 maxin = maxin * 10 + w WEND ' determines maximum value of in in = noth MOD 10 + 1 20 ' w = in MOD 10 + 1 g = w WHILE w < 7 w = w + 1 g = g * 10 + w WEND ' determines g IF noth + in + g = year THEN op1\$ = "+": op2\$ = "+": GOSUB 100 IF noth + in - g = year THEN op1\$ = "+": op2\$ = "-": GOSUB 100 IF noth + in * g = year THEN op1\$ = "+": op2\$ = "*": GOSUB 100 IF in MOD g = 0 AND noth + in / g = year THEN op1\$ = "+": op2\$ = "/": GOSUB 100 IF noth - in + g = year THEN op1\$ = "-": op2\$ = "+": GOSUB 100 IF noth - in - g = year THEN op1\$ = "-": op2\$ = "-": GOSUB 100 IF noth - in * g = year THEN op1\$ = "-": op2\$ = "*": GOSUB 100 IF in MOD g = 0 AND noth - in / g = year THEN op1\$ = "-": op2\$ = "/": GOSUB 100 IF noth * in + g = year THEN op1\$ = "*": op2\$ = "+": GOSUB 100 IF noth * in - g = year THEN op1\$ = "*": op2\$ = "-": GOSUB 100 IF noth * in * g = year THEN op1\$ = "*": op2\$ = "*": GOSUB 100 IF noth * in MOD g = 0 AND noth * in / g = year THEN op1\$ = "*": op2\$ = "/": GOSUB 100 IF noth MOD in = 0 AND noth / in + g = year THEN op1\$ = "/": op2\$ = "+": GOSUB 100 IF noth MOD in = 0 AND noth / in - g = year THEN op1\$ = "/": op2\$ = "-": GOSUB 100 IF noth MOD in = 0 AND noth / in * g = year THEN op1\$ = "/": op2\$ = "*": GOSUB 100 IF noth MOD in = 0 AND noth / in MOD g = 0 AND noth / in / g = year THEN op1\$ = "/": op2\$ = "/": GOSUB 100 in = in * 10 + in MOD 10 + 1: IF in <= maxin THEN 20 noth = noth * 10 + noth MOD 10 + 1: IF noth <= 2345 THEN 10 NEXT year PRINT "see NPR.OUT" 101 ' a\$ = INKEY\$: IF LEN(a\$) = 0 THEN 101 END 100 ' display a solution PRINT #1, noth; : PRINT #1, op1\$; : PRINT #1, in; : PRINT #1, op2\$; : PRINT #1, g; : PRINT #1, "="; : PRINT #1, year RETURN