A positive integer contains each of the base 2N digits from 0 to 2N - 1 exactly once such that the successive pairs of digits from left to right are divisible in turn by 2,3,....,2N. That is, the two digit base 2N number constituted by the ith digit from the left and the (i+1)th digit from the left is divisible by (i+1), for all i = 1,2,3,....,2N-1.
For example, considering the octal number 16743250, we observe that the octal number 32 which is formed by the fifth digit and the sixth digit is not divisible by 6. Therefore, the octal number 16743250 does not satisfy this property.
For which positive integer value(s) of N apart from 5, with 2 ≤ N ≤ 12, do there exist at least one base 2N number that satisfies this property?
Note: Think of this problem as an extension of
Ten-Digit Numbers.
(In reply to
computer solution by Charlie)
Hi Charlie,
as Ady TZIDON pointed out, your code makes the mistake of testing if the number composed of the first n digits is divisible by n where the problem actually asks for the (n-1)th and nth digits to form a base b number that is divisible by n. I have corrected your code as follows to find the proper answers
100 cls
110 Dgs$="0123456789abcdefghijklmnopqrstuvwxyz"
300 for Bse=2 to 24
400 for S=1 to Bse-1
500 Value=S
600 Ss$=mid(Dgs$,S+1,1)
700 gosub *Addon
800 next
900 next
1000 end
1200 *Addon
1201 local Newdig
1300 for Newdig=0 to Bse-1
1400 Nd$=mid(Dgs$,Newdig+1,1)
1500 if instr(Ss$,Nd$)=0 then
1600 :Dn=instr(Dgs$,mid(Ss$,len(Ss$),1))-1
1601 :Value=Dn*Bse+Newdig
1700 :Ss$=Ss$+Nd$
1800 :
1900 :Tst=Value-int(Value/len(Ss$))*len(Ss$)
2000 :if Tst=0 then
2100 ::if len(Ss$)=Bse then
2200 ::
2300 ::print Bse,Ss$
2400 ::
2500 ::
2600 ::else
2700 ::
2800 ::gosub *Addon
2900 ::
3000 ::endif
3100 ::endif
3200 :
3300 :Ss$=left(Ss$,len(Ss$)-1)
3400 :Value=0
3500 :endif
3600 next
3700 return
and this gives the following answers for bases from 2 to 24
2 10
4 3210
5 24130
8 72543610
10 1872549630
10 7812549630
13 6c35a29b17840
13 c635a29b17840
17 7d4cb56a13f9g8e20
17 b74c1da6f539g8e20
17 c4d7b56a13f9g8e20
17 d74cb56a13f9g8e20
now I am currently running a modified version that will test for bases 25 to 62 using capital A-Z to expand past the a-z.
|
Posted by Daniel
on 2009-05-10 09:20:05 |