Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  prime
Language: JAVA
Code:
import java.util.*;
import java.lang.*;
import java.io.*;


class Ideone
{
     
     static int prime(int a)
     {
          int i,c=0;
          for(i=2;i<a;i++)
          {
               if(a%i==0)
               {
                    c=1;
                    break;
              }
         }
         if(c==0)
         return 1;
         else
         return 0;
     }

     public static void main (String[] args) throws java.lang.Exception
     {
          int i,p,s=0;
          for(i=50000;i<100000;i++)
          {
          p=prime(i);
          if(p==1)
          s=s+i;
          }
          System.out.println("Sum="+s);     
}
}          
Comments: