title: Print all prime numbers in range
body: <p>How do I print all prime numbers in a given range?
  Here is the code that I tried, but it's not giving the correct output:</p>
  
  <pre><code>for {set x 2} {$x&lt;100} {incr x} {
  
      for {set i 2} {$i&lt;$x} {incr i} {
  
          set y [expr $x % $i]
          set flag 0
          if {$y == 0}  {
              puts "$x:not a prime no"
              incr flag
              break   
          }
      }
  
      if {$flag ==1} {
          puts "$x: prime no"
      }
  }
  </code></pre>