1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. void slowoutput()
  7. {
  8. int userinput = 100;
  9. bool geenpriem = 0;
  10. cout << "From 0 to: ";
  11. cin >> userinput;
  12. system("echo %time%");
  13. for(int x = 0;x <= userinput;x++)
  14. {
  15. for(int y = x - 1;y > 1;y--)
  16. {
  17. if(x % y == 0)
  18. {
  19. geenpriem = 1;
  20. break;
  21. }
  22. }
  23. if(geenpriem == 0)
  24. cout << x << ", ";
  25. geenpriem = 0;
  26. }
  27. cout << endl;
  28. system("echo %time%");
  29. system("pause");
  30. }
  31.  
  32. void slow()
  33. {
  34. int userinput = 100;
  35. bool geenpriem = 0;
  36. cout << "From 0 to: ";
  37. cin >> userinput;
  38. system("echo %time%");
  39. for(int x = 0;x <= userinput;x++)
  40. {
  41. for(int y = x - 1;y > 1;y--)
  42. {
  43. if(x % y == 0)
  44. {
  45. geenpriem = 1;
  46. break;
  47. }
  48. }
  49. geenpriem = 0;
  50. }
  51. cout << endl;
  52. system("echo %time%");
  53. system("pause");
  54. }
  55.  
  56. void fastoutput()
  57. {
  58. int userinput = 100;
  59. bool geenpriem = 0;
  60. cout << "From 0 to: ";
  61. cin >> userinput;
  62. system("echo %time%");
  63. if(userinput % 2 == 0)
  64. userinput--;
  65. for(int x = 1;x <= userinput;x++)
  66. {
  67. for(int y = x - 2;y > 1;y--)
  68. {
  69. if(x % y == 0)
  70. {
  71. geenpriem = 1;
  72. break;
  73. }
  74. y--;
  75. }
  76. if(geenpriem == 0)
  77. cout << x << ", ";
  78. geenpriem = 0;
  79. x++;
  80. }
  81. cout << endl;
  82. system("echo %time%");
  83. system("pause");
  84. }
  85.  
  86. void fast()
  87. {
  88. int userinput = 100;
  89. bool geenpriem = 0;
  90. cout << "From 0 to: ";
  91. cin >> userinput;
  92. system("echo %time%");
  93. if(userinput % 2 == 0)
  94. userinput--;
  95. for(int x = 1;x <= userinput;x++)
  96. {
  97. for(int y = x - 2;y > 1;y--)
  98. {
  99. if(x % y == 0)
  100. {
  101. geenpriem = 1;
  102. break;
  103. }
  104. y--;
  105. geenpriem = 0;
  106. }
  107. x++;
  108. }
  109. cout << endl;
  110. system("echo %time%");
  111. system("pause");
  112. }
  113.  
  114. void slowfile()
  115. {
  116. int userinput = 100;
  117. bool geenpriem = 0;
  118. cout << "From 0 to: ";
  119. cin >> userinput;
  120. ofstream output;
  121. output.open ("Slow.txt");
  122. system("echo %time%");
  123. for(int x = 0;x <= userinput;x++)
  124. {
  125. for(int y = x - 1;y > 1;y--)
  126. {
  127. if(x % y == 0)
  128. {
  129. geenpriem = 1;
  130. break;
  131. }
  132. }
  133. if(geenpriem == 0)
  134. output << x << ", ";
  135. geenpriem = 0;
  136. }
  137. cout << endl;
  138. system("echo %time%");
  139. output.close();
  140. system("pause");
  141. }
  142.  
  143. void fastfile()
  144. {
  145. int userinput = 100;
  146. bool geenpriem = 0;
  147. cout << "From 0 to: ";
  148. cin >> userinput;
  149. ofstream output;
  150. output.open ("Fast.txt");
  151. system("echo %time%");
  152. if(userinput % 2 == 0)
  153. userinput--;
  154.  
  155. for(int x = 1;x <= userinput;x++)
  156. {
  157. for(int y = x - 2;y > 1;y--)
  158. {
  159. if(x % y == 0)
  160. {
  161. geenpriem = 1;
  162. break;
  163. }
  164. y--;
  165. }
  166. if(geenpriem == 0)
  167. output << x << ", ";
  168. geenpriem = 0;
  169. x++;
  170. }
  171. cout << endl;
  172. system("echo %time%");
  173. output.close();
  174. system("pause");
  175. }
  176.  
  177. void uber()
  178. {
  179. int userinput = 100;
  180. int y = 0;
  181. bool geenpriem = 0;
  182. cout << "From 0 to: ";
  183. cin >> userinput;
  184. system("echo %time%");
  185. if(userinput % 2 == 0)
  186. userinput--;
  187. for(int x = 1;x <= userinput;x++)
  188. {
  189. y = x / 2;
  190. if(y % 2 == 0)
  191. y--;
  192. for(y;y > 1;y--)
  193. {
  194. if(x % y == 0)
  195. {
  196. geenpriem = 1;
  197. break;
  198. }
  199. y--;
  200. }
  201. geenpriem = 0;
  202. x++;
  203. }
  204. cout << endl;
  205. system("echo %time%");
  206. system("pause");
  207. }
  208.  
  209. void uberarray()
  210. {
  211. int count = 0;
  212. int primes[100000] = {0};
  213. int userinput = 100;
  214. int y = 0;
  215. bool geenpriem = 0;
  216. cout << "From 0 to: ";
  217. cin >> userinput;
  218. system("echo %time%");
  219. if(userinput % 2 == 0)
  220. userinput--;
  221. for(int x = 1;x <= userinput;x++)
  222. {
  223. y = x / 2;
  224. if(y % 2 == 0)
  225. y--;
  226. for(y;y > 1;y--)
  227. {
  228. if(x % y == 0)
  229. {
  230. geenpriem = 1;
  231. break;
  232. }
  233. y--;
  234. }
  235. if(geenpriem == 0)
  236. {
  237. primes[count] = x;
  238. count++;
  239. if(count > 99999)
  240. break;
  241. }
  242. geenpriem = 0;
  243. x++;
  244. }
  245. ofstream output;
  246. output.open ("Uberbuffer.txt");
  247. for(int z = 0;z <= count;z++)
  248. {
  249. output << primes[z] << ", ";
  250. }
  251. cout << endl;
  252. system("echo %time%");
  253. system("pause");
  254. }
  255.  
  256. void uberfile()
  257. {
  258. int userinput = 100;
  259. int y = 0;
  260. bool geenpriem = 0;
  261. cout << "From 0 to: ";
  262. cin >> userinput;
  263. ofstream output;
  264. output.open ("Uber.txt");
  265. system("echo %time%");
  266. if(userinput % 2 == 0)
  267. userinput--;
  268.  
  269. for(int x = 1;x <= userinput;x++)
  270. {
  271. y = x / 2;
  272. if(y % 2 ==0)
  273. y--;
  274. for(y = x - 2;y > 1;y--)
  275. {
  276. if(x % y == 0)
  277. {
  278. geenpriem = 1;
  279. break;
  280. }
  281. y--;
  282. }
  283. if(geenpriem == 0)
  284. output << x << ", ";
  285. geenpriem = 0;
  286. x++;
  287. }
  288. cout << endl;
  289. system("echo %time%");
  290. output.close();
  291. system("pause");
  292. }
  293.  
  294. void uberoutput()
  295. {
  296. int userinput = 100;
  297. int y = 0;
  298. bool geenpriem = 0;
  299. cout << "From 0 to: ";
  300. cin >> userinput;
  301. system("echo %time%");
  302. if(userinput % 2 == 0)
  303. userinput--;
  304. for(int x = 1;x <= userinput;x++)
  305. {
  306. y = x / 2;
  307. if(y % 2 == 0)
  308. y--;
  309. for(y;y > 1;y--)
  310. {
  311. if(x % y == 0)
  312. {
  313. geenpriem = 1;
  314. break;
  315. }
  316. y--;
  317. }
  318. if(geenpriem == 0)
  319. cout << x << ", ";
  320. geenpriem = 0;
  321. x++;
  322. }
  323. cout << endl;
  324. system("echo %time%");
  325. system("pause");
  326. }
  327.  
  328. void omgwtfbbq()
  329. {
  330. int userinput = 100;
  331. int x = 0;
  332. int y = 0;
  333. int z = 0;
  334. bool geenpriem = 0;
  335. cout << "From 0 to: ";
  336. cin >> userinput;
  337. system("echo %time%");
  338. if(userinput % 2 == 0)
  339. userinput--;
  340. for(x = 1;x <= userinput;x++)
  341. {
  342. z = x / 3;
  343. for(y = 3;y < z;y++)
  344. {
  345. if(x % y == 0)
  346. {
  347. geenpriem = 1;
  348. break;
  349. }
  350. y++;
  351. geenpriem = 0;
  352. }
  353. x++;
  354. }
  355. cout << endl;
  356. system("echo %time%");
  357. ofstream output;
  358. output.open ("Uber.txt");
  359. output.close();
  360. system("pause");
  361. }
  362.  
  363. void omgwtfbbqbuffer()
  364. {
  365. int count = 0;
  366. int primes[100000] = {0};
  367. int userinput = 100;
  368. int x = 0;
  369. int y = 0;
  370. int z = 0;
  371. bool geenpriem = 0;
  372. cout << "From 0 to: ";
  373. cin >> userinput;
  374. system("echo %time%");
  375. if(userinput % 2 == 0)
  376. userinput--;
  377. for(int x = 1;x <= userinput;x++)
  378. {
  379. y = x / 3;
  380. if(y % 2 == 0)
  381. y--;
  382. for(y = 3;y < z;y++)
  383. {
  384. if(x % y == 0)
  385. {
  386. geenpriem = 1;
  387. break;
  388. }
  389. y++;
  390. }
  391. if(geenpriem == 0)
  392. {
  393. primes[count] = x;
  394. count++;
  395. if(count > 99999)
  396. break;
  397. }
  398. geenpriem = 0;
  399. x++;
  400. }
  401. ofstream output;
  402. output.open ("OMGWTFBBQ.txt");
  403. for(int z = 0;z <= count;z++)
  404. {
  405. output << primes[z] << ", ";
  406. }
  407. cout << endl;
  408. system("echo %time%");
  409. system("pause");
  410. }
  411.  
  412. void main()
  413. {
  414. int choice = 0;
  415. do
  416. {
  417. system("cls");
  418. 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: ";
  419. cin >> choice;
  420. if(choice == 1)
  421. fastoutput();
  422. if(choice == 2)
  423. fast();
  424. if(choice == 3)
  425. fastfile();
  426. if(choice == 4)
  427. slowoutput();
  428. if(choice == 5)
  429. slow();
  430. if(choice == 6)
  431. slowfile();
  432. if(choice == 7)
  433. uberoutput();
  434. if(choice == 8)
  435. uber();
  436. if(choice == 9)
  437. uberfile();
  438. if(choice == 10)
  439. uberarray();
  440. if(choice == 11)
  441. omgwtfbbq();
  442. if(choice == 12)
  443. omgwtfbbqbuffer();
  444. if(choice > 12)
  445. cout << "Invalid choice" << endl;
  446. }while(choice != 0);
  447. }