Monday, September 14, 2015

Generate Prime Numbers list between 1 and 100

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jv.prim;
/**
 * Generate Prime between 1 and 100
 * @author sm rabbi
 */

public class JvPrim {
    /**
     * @param args the command line arguments
     **/

    public static void main(String[] args) {
       
        int a,b,c;
        for(a=1;a<=100;a++)
        {
            c=1;
            for(b=2;b<=a/2;b++)
            {
                if(a%b == 0)
                {
                    c=0;
                    //System.out.println("not prime "+ a + " " + b + " " +a%b);
                    break;
                }
            }
           
            if(c==1)
            {
                System.out.println("prime= " +a);
            }
        }
    }
}
     

1 comment:

  1. Hi admin...your blog was interesting.All the Details were explained in clear manner. Thanks for sharing this blog. Duplicate Payment Review | Continuous Transaction Monitoring | Duplicate Payment Recovery

    ReplyDelete