Here's a quick and dirty solution to the following task:
Arrange digits 1,...,9 so that the first two form a number divisible by 2, the first three form a number divisible by 3, etc..

See Joe Riel's blog for more information.

Hmm, the blog software seems to prefix "50_" to the filename... What's that?

Update - Nov 29, 2006 - Add the HTML export and link to the file

> restart:

> ds:={$1..9}; # set of digits (initially 1..9)

> # first digit (a) always divisible by 1, hence no "if" query

> printlevel:=0:

> for a in ds do
ds := ds minus {a}:
for b in ds do
if 10*a+b mod 2 = 0 then
ds := ds minus {b}:
for c in ds do
if 100*a+10*b+c mod 3 = 0 then
ds := ds minus {c}:
for d in ds do
if 1000*a+100*b+10*c+d mod 4 = 0 then
ds := ds minus {d}:
for e in ds do
if 10^4*a+1000*b+100*c+10*d+e mod 5 = 0 then
ds := ds minus {e}:
for f in ds do
if 10^5*a+10^4*b+1000*c+100*d+10*e+f mod 6 = 0 then
ds := ds minus {f}:
for g in ds do
if 10^6*a+10^5*b+10^4*c+1000*d+100*e+10*f+g mod 7 = 0 then
ds := ds minus {g}:
for h in ds do
if 10^7*a+10^6*b+10^5*c+10^4*d+1000*e+100*f+10*g+h mod 8 = 0 then
ds := ds minus {h}:
for i in ds do # last digit, no set operations necessary
if 10^8*a+10^7*b+10^6*c+10^5*d+10^4*e+1000*f+100*g+10*h+i mod 9 = 0 then
lprint(a,b,c,d,e,f,g,h,i)
else
next
end if
end do:
ds := ds union {h}
else
next
end if
end do:
ds := ds union {g}
else
next
end if
end do:
ds := ds union {f}
else
next
end if
end do:
ds := ds union {e}
else
next
end if
end do:
ds := ds union {d}
else
next
end if
end do:
ds := ds union {c}
else
next
end if
end do:
ds := ds union {b}
else
next
end if
end do:
ds := ds union {a}
end do;

3, 8, 1, 6, 5, 4, 7, 2, 9

>

>

Maple Equation

This post was generated using the MaplePrimes File Manager

View 1_kopfumkopf.mw on MapleNet or Download 1_kopfumkopf.mw
View file details


Please Wait...