title: Finding the biggest number divisible by other
body: <p>I need to prepare an algorithm, which will display <code>n-th</code> digit (counting from right) of the biggest number divisible by <code>B-1</code> where <code>B</code> is the base of specified number system. The number can only consist of digits provided in the input.</p>
  
  <p>So for example: The base of number system is <code>3</code>, the provided digits are <code>[0, 1, 2]</code> and I'm looking for <code>2nd</code> digit. So that I need to find <code>2nd</code> digit of the biggest number consisted of <code>0, 1, 2</code> divisible by <code>2</code>. In this case the result will be <code>2</code>, because the biggest number was 20<sub>3</sub>.</p>
  
  <p>I've tried to find this algorithm in many ways, but I cannot find any connection between input and output values.</p>