title: How many 8 digit numbers are there which are both divisible by 18 and every digit is either a 1, 2 or 3?
body: <p>Solving this problem using python involves making sure that all the individual digits of numbers between 10,000,000 and 99,999,999 are 1, 2 or 3 and if the numbers are also divisible by 18. The answer (win) is the number of times both these conditions are true. </p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>count=10000000
  win=0
  yes=False
  while(True):  
      def check():
          i=0
          for i in range(0,7):
              if count[i]==1 or count[i]==2 or count[i]==3:
                  yes=True
              else:
                  return(False)
          return(yes)
  
      while True:
  
          if count%18==0 and check()==True:
              win+=1
  
  
  
      print(win)
      count+=1
      if count&gt;99999999:
          exit()
  </code></pre>
  
  <p>Any help is greatly appreciated.    </p>