My Cpp approach with correct solution

programming
Tags: #<Tag:0x00007f2424a7d9c0>

#1

bool isPrime(int n){
if(n<=1){
return false;
}
if(n==2 || n == 3){
return true;
}

if(n%2==0 || n%3==0){
return false;
}

for(int i=5;i*i<=n;i=i+6){
if(n%i==0 || n%(i+2)==0){
return false;
}
}
return true;
}

vector Solution::primesum(int A) {

vector v;
for(int i=2;i<A;i++){
for(int j=2;j<A;j++){

        if((i+j)==A){
            
          if(isPrime(i) && isPrime(j)){
                
          v.push_back(i);
          v.push_back(j);
          return v;
        }
    }
}

}
return v;

}