#include <iostream>
#include <fstream>
using namespace std;
void slowoutput()
{
int userinput = 100;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
for(int x = 0;x <= userinput;x++)
{
for(int y = x - 1;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
}
if(geenpriem == 0)
cout << x << ", ";
geenpriem = 0;
}
cout << endl;
system("echo %time%");
system("pause");
}
void slow()
{
int userinput = 100;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
for(int x = 0;x <= userinput;x++)
{
for(int y = x - 1;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
}
geenpriem = 0;
}
cout << endl;
system("echo %time%");
system("pause");
}
void fastoutput()
{
int userinput = 100;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
for(int y = x - 2;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y--;
}
if(geenpriem == 0)
cout << x << ", ";
geenpriem = 0;
x++;
}
cout << endl;
system("echo %time%");
system("pause");
}
void fast()
{
int userinput = 100;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
for(int y = x - 2;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y--;
geenpriem = 0;
}
x++;
}
cout << endl;
system("echo %time%");
system("pause");
}
void slowfile()
{
int userinput = 100;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
ofstream output;
output.open ("Slow.txt");
system("echo %time%");
for(int x = 0;x <= userinput;x++)
{
for(int y = x - 1;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
}
if(geenpriem == 0)
output << x << ", ";
geenpriem = 0;
}
cout << endl;
system("echo %time%");
output.close();
system("pause");
}
void fastfile()
{
int userinput = 100;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
ofstream output;
output.open ("Fast.txt");
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
for(int y = x - 2;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y--;
}
if(geenpriem == 0)
output << x << ", ";
geenpriem = 0;
x++;
}
cout << endl;
system("echo %time%");
output.close();
system("pause");
}
void uber()
{
int userinput = 100;
int y = 0;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
y = x / 2;
if(y % 2 == 0)
y--;
for(y;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y--;
}
geenpriem = 0;
x++;
}
cout << endl;
system("echo %time%");
system("pause");
}
void uberarray()
{
int count = 0;
int primes[100000] = {0};
int userinput = 100;
int y = 0;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
y = x / 2;
if(y % 2 == 0)
y--;
for(y;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y--;
}
if(geenpriem == 0)
{
primes[count] = x;
count++;
if(count > 99999)
break;
}
geenpriem = 0;
x++;
}
ofstream output;
output.open ("Uberbuffer.txt");
for(int z = 0;z <= count;z++)
{
output << primes[z] << ", ";
}
cout << endl;
system("echo %time%");
system("pause");
}
void uberfile()
{
int userinput = 100;
int y = 0;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
ofstream output;
output.open ("Uber.txt");
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
y = x / 2;
if(y % 2 ==0)
y--;
for(y = x - 2;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y--;
}
if(geenpriem == 0)
output << x << ", ";
geenpriem = 0;
x++;
}
cout << endl;
system("echo %time%");
output.close();
system("pause");
}
void uberoutput()
{
int userinput = 100;
int y = 0;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
y = x / 2;
if(y % 2 == 0)
y--;
for(y;y > 1;y--)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y--;
}
if(geenpriem == 0)
cout << x << ", ";
geenpriem = 0;
x++;
}
cout << endl;
system("echo %time%");
system("pause");
}
void omgwtfbbq()
{
int userinput = 100;
int x = 0;
int y = 0;
int z = 0;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(x = 1;x <= userinput;x++)
{
z = x / 3;
for(y = 3;y < z;y++)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y++;
geenpriem = 0;
}
x++;
}
cout << endl;
system("echo %time%");
ofstream output;
output.open ("Uber.txt");
output.close();
system("pause");
}
void omgwtfbbqbuffer()
{
int count = 0;
int primes[100000] = {0};
int userinput = 100;
int x = 0;
int y = 0;
int z = 0;
bool geenpriem = 0;
cout << "From 0 to: ";
cin >> userinput;
system("echo %time%");
if(userinput % 2 == 0)
userinput--;
for(int x = 1;x <= userinput;x++)
{
y = x / 3;
if(y % 2 == 0)
y--;
for(y = 3;y < z;y++)
{
if(x % y == 0)
{
geenpriem = 1;
break;
}
y++;
}
if(geenpriem == 0)
{
primes[count] = x;
count++;
if(count > 99999)
break;
}
geenpriem = 0;
x++;
}
ofstream output;
output.open ("OMGWTFBBQ.txt");
for(int z = 0;z <= count;z++)
{
output << primes[z] << ", ";
}
cout << endl;
system("echo %time%");
system("pause");
}
void main()
{
int choice = 0;
do
{
system("cls");
cout << "1. Fast with output.\n2. Fast without output\n3. Fast with output to a file.\n4. Slow with output\n5. Slow without output\n6. Slow with output to a file.\n7. Uber fast with output.\n8. Uber fast without output.\n9. Uber fast with output to a file.\n10.Uber fast with output to a file (with buffer).\n11.OMGWTFBBQ\n\n0. Exit\n\nYour selection: ";
cin >> choice;
if(choice == 1)
fastoutput();
if(choice == 2)
fast();
if(choice == 3)
fastfile();
if(choice == 4)
slowoutput();
if(choice == 5)
slow();
if(choice == 6)
slowfile();
if(choice == 7)
uberoutput();
if(choice == 8)
uber();
if(choice == 9)
uberfile();
if(choice == 10)
uberarray();
if(choice == 11)
omgwtfbbq();
if(choice == 12)
omgwtfbbqbuffer();
if(choice > 12)
cout << "Invalid choice" << endl;
}while(choice != 0);
}