/* 225 divisor problem in Picat. From http://www.quora.com/Mathematics/What-is-the-smallest-number-divisible-by-225-that-consists-of-all-1s-and-0s """ What is the smallest number divisible by 225 that consists of all 1s and 0s? """ Answer: 11111111100 This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => N = 11, X = new_list(N), X :: 0..1, Y :: 1..(10**N)-1, to_num(X,10,Y), Y mod 225 #= 0, Vars = X ++ [Y], solve($[min(Y)],Vars), println(Y), nl. % % converts a number Num to/from a list of integer List given a base Base % to_num(List, Base, Num) => Len = length(List), Num #= sum([List[I]*Base**(Len-I) : I in 1..Len]).