import java.util.Scanner;
public class SumOfPrimeNo {
public static void main(String[] args) {
int temp, no,sum=0,count=0,loop1=0,loop2=0;;
System.out.println("--The sum of the All prime Number in Between 2 to ??--");
Scanner sc = new Scanner(System.in);
System.out.println("Enter a Number ");
no = sc.nextInt();
for (int j = 2; j <= no; j++)
{
loop1++;
temp=0;
for (int i = 2; i <= j/2; i++) {
loop2++;
if (j % i == 0) {
temp=1;
break;
}
}
if (temp==0) {
System.out.print(j+" ");
count++;
sum=sum+j;
}
}
System.out.println("
The Total no of Prime Number between 1 to "+no+" is = "+count);
System.out.println("The sum of all Prime Numbers in between 1 to "+no+" is = "+sum);
System.out.println("How many times Loop ran = "+(loop1+loop2)+" times,"+" loop1 = "+loop1+" times, "+"loop2 = "+loop2+" times");
}}