Dateien nach „BSP_1_F“ hochladen

This commit is contained in:
Georg Thomas Mandl 2025-10-22 23:12:23 +02:00
commit 40e2b29d95
5 changed files with 212 additions and 0 deletions

31
BSP_1_F/main.cpp Normal file
View file

@ -0,0 +1,31 @@
#include "bsp_1_f.h"
#include "mayer_primes.h"
#include <iostream>
#include <algorithm>
#include <chrono>
// BSP 1_F
using namespace std;
int main()
{
// Auswertung für n=100000 bzw herausfinden der Zahl, welche die meisten Dekompositionen hat
vector<int> v = count_goldbach(1e5);
auto ip = max_element(v.begin(), v.end());
cout << "Zahl zwischen [4,1e5] mit meisten Zerlegungen" << endl;
cout << "Zahl k " << distance(v.begin(), ip)*2+4 << " mit " << *ip << " Zerlegungen" << endl;
cout << "Zeitmessungen" << endl;
vector<int> nvec{static_cast<int>(1e4), static_cast<int>(1e5), static_cast<int>(4*1e5), static_cast<int>(1e6), static_cast<int>(2*1e6)}; // Vektor für n
for(size_t k=0; k<nvec.size(); ++k)
{
auto timestart = chrono::system_clock::now();
vector<int> vall = count_goldbach(nvec[k]);
auto timeend = chrono::system_clock::now();
auto time = chrono::duration_cast<chrono::milliseconds>(timeend - timestart);
cout << "n = " << nvec[k] << " time: " << time.count() << " ms" << endl << endl;
}
// cout << single_goldbach(694) << endl;
// cout << count_goldbach(10000)[690/2] << endl;
return 0;
}