#include <vector>
#include <iostream>
#include <cmath>
using namespace std;

bool isit_prime(int n){
    for(int i=2; i <= sqrt(n) ; i++){
        if(n%i == 0)
        {
            return false;
        }
    }
    return true;
}
int solution(vector<int> nums) {
    int answer = 0;
    int tmp = 0;
    int first =0, second = 0, third  = 0;
    for(int i = 0; i < nums.size()-2; i++){
        first = nums[i];
        for(int j = i+1; j < nums.size()-1; j++){
            second = nums[j];
            for(int k = j+1; k < nums.size(); k++){
                third = nums[k];
                tmp = first + second + third;
                if(isit_prime(tmp)){
                    cout<< "tmp: " << tmp << endl;
                    answer+=1;
                }
            }
        }
    }
    return answer;
}

+ Recent posts