title: How can I print the prime numbers ending with 1 in a given range and the nearest one after b?
body: <ul>
  <li><p>Sample input :
  10 
  100</p></li>
  <li><p>Sample output :
  11,31,41,61,71,101</p></li>
  <li><p>from the above code I can get the sample output value upto the value 71,how can I get nearest prime number ending with 1 after b. </p></li>
  </ul>
  
  <p>Here is the code I tried:</p>
  
  <pre><code>import java.util.*;
  public class Program{
  public static void main(String[] args){
      Scanner in=new Scanner(System.in);
      int a=in.nextInt();
      int b=in.nextInt();
      int i,j,count;
      for(i=a;i&lt;=b;i++)
      {
          for(j=2;j&lt;=b;j++)
          {
              if(i%j==0)
              break;
          }
          if(j==i &amp;&amp; j%10==1) 
          {
              System.out.println(i);
          }
      }
  } 
  </code></pre>