title: How to print out all numbers that are not divisible by 3 & 7 in the range of two integers using a while-loop?
body: <blockquote>
  <p>Details: Take two integers numX and numY, and print integer numbers
  ranging from numX to numY excluding those that are divisible by 3 &amp; 7.
  Besides, if the sum  of the printed integer numbers is greater than 5
  times the highest value, the  code immediately stops printing the
  number.</p>
  </blockquote>
  <p>Sample Input:</p>
  <pre><code>&gt;numA = 31
  &gt;numB = 14
  </code></pre>
  <p>Sample Output:</p>
  <pre><code>&gt;14 15 16 17 18 19 20 22 23
  </code></pre>
  <p><em>the output stops at 23 because <strong>14+...+23 &gt; (31 * 5 = 155)</strong></em></p>
  <p>I think this question could be solved easily by using <code>for</code> loop, however, the practice requires using <code>while</code> loop. Please help.</p>
  <p>Here are my codes using <code>while</code> loop to solve it but not working at all:</p>
  <pre><code>numA = int(input(&quot;Enter numA: &quot;))
  numB = int(input(&quot;Enter numB: &quot;))
  
  tempInt = ''
  
  while numA &gt; numB:
      if numA % 21 == 0:
          tempInt = tempInt + str(numA) + &quot; &quot;
          numA -= 1
  while numA &lt; numB:
      if numA % 21 == 0:
          tempInt = tempInt + str(numA) + &quot; &quot;
          numA += 1
  
  tempInt = tempInt + str(numA)
  print(tempInt)
  </code></pre>