#include "bsp_1_f.h"
#include "mayer_primes.h"
#include "algorithm"
#include <iostream>

using namespace std;

int single_goldbach(const int &k)
{
    vector<int> primes = get_primes(k);
    int amount = 0;
    for(size_t it = 0; primes[it]<=k/2.0; ++it) //für Primzahl größer als k/2 haben wir bereits Zerlegung gezählt: 3+7 = 7+3
    {
       for(size_t j = it; j<primes.size(); ++j)
       {
           if(primes[it] + primes[j] == k)
           {
               amount += 1;
           }
       }
    }

    return amount;
}


vector<int> count_goldbach(const int &n)
{
    vector<int> count_vec((n-4)/2+1,0);
    vector<int> primes = get_primes(n);
    for(size_t k=0; k < primes.size() && primes[k]<=n/2; ++k)
    {
        for(size_t i=k; i<primes.size(); ++i)
        {
            int sum = primes[k] + primes[i];
            if(sum<=n)
            {
                count_vec[(sum-4)/2] += 1;
            }
        }
    }

    return count_vec;
}
