Faculty for Electrical Engineering and Informatics, BME
Engineering Programme in English |
MSc Course in Software Engineering
Autumn semester 2007/08
|
div
2 (where div
is integer division),
ai <
an+1-i.
Write a function called smallheaded
which satisfies the following:
(* smallheaded : int -> int smallheaded a = b, where 'b' >= 2 is the smallest number, for which the digits of 'a' written in 'b'-base form a small-headed number sequence *)You are allowed to define auxiliary functions.
smallheaded 4 = 5 (* because 45 = 4 is smallheaded, but 44 = 1 0, 43 = 1 1, 42 = 1 0 0 are not *) smallheaded 11 = 3 (* because 113 = 1 0 2 is smallheaded, but 112 = 1 0 1 1 are not *) smallheaded 145 = 7 (* because 1457 = 2 6 5 is smallheaded, but... *) smallheaded 293 = 3 (* because 2933 = 1 0 1 2 1 2 is smallheaded, but ... *)In the examples, dr denote the decimal number d written in r-base.