program to print series of prime numbers using java

后端 未结 6 1608
太阳男子
太阳男子 2021-01-25 01:40

This code is to print the series of prime number up to given limit but when I am trying to execute this,it goes into infinite loop.

import java.io.*;
class a
{
          


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 02:23

    After correction i got the series of prime numbers.

    import java.io.*;
    class a
    {
        public static void main(String s[]) throws IOException
        {
            int count=1,count1=0;
            String st;
            System.out.println("how many prime no. do you want");
            BufferedReader obj= new BufferedReader (new InputStreamReader (System.in));
            st=obj.readLine();
            int n=Integer.parseInt(st);
            int num=2;
            while(count<=n)
            {
                count1=0;
                for(int i=2;i

提交回复
热议问题