Prove that among any 18 consecutive 3-digit numbers there must be at least one which is divisible by the sum of its digits.
These are the 3-digit numbers that are divisible by the sums of their digits:
100 102 108 110 111 112 114 117 120 126 132 133 135 140 144 150
152 153 156 162 171 180 190 192 195 198 200 201 204 207 209 210
216 220 222 224 225 228 230 234 240 243 247 252 261 264 266 270
280 285 288 300 306 308 312 315 320 322 324 330 333 336 342 351
360 364 370 372 375 378 392 396 399 400 402 405 407 408 410 414
420 423 432 440 441 444 448 450 460 465 468 476 480 481 486 500
504 506 510 511 512 513 516 518 522 531 540 550 552 555 558 576
588 592 594 600 603 605 612 621 624 629 630 640 644 645 648 660
666 684 690 700 702 704 711 715 720 730 732 735 736 738 756 770
774 777 780 782 792 800 801 803 804 810 820 825 828 832 840 846
864 870 874 880 882 888 900 902 910 912 915 918 935 936 954 960
966 972 990 999
The Maximum difference between successive entries is 18.
These are the gaps, where the difference is 18, and so there are 17 that are skipped over:
18 558 576
18 666 684
18 738 756
18 846 864
18 936 954
18 972 990
DECLARE FUNCTION sod# (x#)
DEFDBL A-Z
CLS
FOR n = 100 TO 999
s = sod(n)
IF n MOD s = 0 THEN
IF prev > 0 THEN
diff = n - prev
IF diff > max THEN max = diff
END IF
PRINT n;
prev = n
END IF
NEXT
PRINT : PRINT max: PRINT
FOR n = 100 TO 999
s = sod(n)
IF n MOD s = 0 THEN
IF prev > 0 THEN
diff = n - prev
IF diff = max THEN PRINT diff, prev; n
END IF
prev = n
END IF
NEXT
FUNCTION sod (x)
sum = 0
n$ = LTRIM$(STR$(x))
FOR i = 1 TO LEN(n$)
sum = sum + VAL(MID$(n$, i, 1))
NEXT
sod = sum
END FUNCTION
|
Posted by Charlie
on 2010-08-06 13:59:53 |