(In reply to
Adding up those 9-digit numbers by Charlie)
The program previously shown ensured that not only did the first two digits, as well as digits 6 and 7 (by checking digits 3 and 4 in the palindrome), need to be non-consecutive, it also made sure the members of each pair were not equal to each other. This has been corrected in lines 30 and 60 of the below programs. The new totals, in decimal and then in the digits of the respective bases, follow the run command in each.
The units digit in the respective bases remains 0, but the coincidental unit-digit zero in the decimal representation no longer takes place.
10 for A=1 to 11
20 for B=0 to 11
30 if abs(A-B)<>1 then
40 :for C=0 to 11
50 :for D=0 to 11
60 :if abs(C-D)<>1 then
70 :for E=0 to 11
80 :N=A*(12^8+1)
90 :N=N+B*(12^7+12)
100 :N=N+C*(12^6+12^2)
110 :N=N+D*(12^5+12^3)
120 :N=N+E*12^4
130 :Tot=Tot+N
140 :next
144 :endif
145 :next
146 :next
150 next B
160 next A
200 print Tot
300 N=Tot
305 S$=" "
310 while N>0
320 D=N@12:N=N\12
330 S$=str(D)+S$
340 wend
360 print S$
run
457090751915976
4 3 3 2 3 2 11 11 11 8 6 5 10 0
OK
10 for A=1 to 15
20 for B=0 to 15
30 if abs(A-B)<>1 then
40 :for C=0 to 15
50 :for D=0 to 15
60 :if abs(C-D)<>1 then
70 :for E=0 to 15
80 :N=A*(16^8+1)
90 :N=N+B*(16^7+16)
100 :N=N+C*(16^6+16^2)
110 :N=N+D*(16^5+16^3)
120 :N=N+E*16^4
130 :Tot=Tot+N
140 :next
144 :endif
145 :next
146 :next
150 next B
160 next A
200 print Tot
300 N=Tot
305 S$=" "
310 while N>0
320 D=N@16:N=N\16
330 S$=str(D)+S$
340 wend
360 print S$
run
27956539129767392
6 3 5 2 5 2 15 15 15 10 10 5 14 0
OK
|
Posted by Charlie
on 2015-01-08 07:59:42 |