View Code of Problem 27

#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int a,b,flag=0;
    while(cin>>a>>b){
        int sum = 0;
        if(a==0){
            a=1;
        }
        for(int i=a+1;i<b;i++){
            flag = 0;
            for(int j=2;j<i;j++){
                if(i%j==0){
                    flag =1;
                    break;
                }
            }
            if(flag==0){
                sum+=i;
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 27