6300846559 is such that 6 is divisible by 2; 63, by 3; 630, by 5; 6300, by 7; and, in general, if you take its first N digits, it will be divisible by the Nth prime.
There is only one other such 10 digit number: can you find it?
(In reply to
Solution (VB program) by Penny)
Rather than have code to test each level separately, the following QuickBasic code uses recursion to add a level at a time, calling the same code over again:
DECLARE SUB buildOn (s$)
CLEAR , , 5000
DATA 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61
DEFDBL AZ
DIM SHARED prime(18)
FOR i = 1 TO 18
READ prime(i)
NEXT
buildOn ""
SUB buildOn (s$)
l = LEN(s$) + 1
had = 0
FOR i = 0 TO 9
d$ = LTRIM$(STR$(i))
s1$ = s$ + d$
v = VAL(s1$)
q = INT(v / prime(l))
r = v  q * prime(l)
IF r = 0 THEN
had = 1
IF l = UBOUND(prime) THEN
PRINT s1$; "*"
ELSE
buildOn s1$
END IF
END IF
NEXT i
IF had = 0 THEN
PRINT USING "## &"; LEN(s$); s$
END IF
END SUB
This version shows all the possible numbers, (up to 18 digits, but none need that), as they are built up. Below, I've left out the ones with leading zeros; none of those reached 10 digits, except 000000... which could go on forever. Each string is preceded by its length; indeed in two cases it reaches 10 and 10 is never exceeded.
4 2100
9 210769470
8 21560592
7 2401369
4 2408
7 2450890
5 24574
6 270270
6 270933
7 2751195
8 27588627
8 42009551
7 4207585
4 4256
6 450125
7 4508927
8 45507812
5 45573
5 48026
6 480922
7 4851086
7 4858753
6 600600
7 6055536
10 6300846559
7 6307476
5 63569
6 660114
7 6608818
9 665067264
5 66572
5 69025
6 690911
4 6951
7 6958644
4 8106
8 81554270
8 84007379
8 84073670
6 845689
6 870103
7 8708709
7 8750563
10 8757193191

Posted by Charlie
on 20050104 16:00:11 