Set Operations

This program generates the intersection, union, relative composition, cross product, and power set, of given input (which generates the sets the operations are performed on. ///////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <sstream> //////////////////////////////////////////////////////////////////////////////// std::vector<std::string> createSet(void); // creates set from user input std::vector<std::string> getIntersection(std::vector<std::string> set_A, std::vector<std::string> set_B); …

Modulo Congruence

//////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <math> //////////////////////////////////////////////////////////////////////////////// void numberQuery(unsigned long long &a, unsigned long long &n, unsigned long long &m); unsigned long long powertworesidual(unsigned long long a, unsigned long long n, unsigned long long m); unsigned long long nonpowertworesidual(unsigned long long a, unsigned long long n, unsigned long long m); //////////////////////////////////////////////////////////////////////////////// …

Solving a second order linear homogenous recurrence relation with consistent coefficients

#include <iostream> #include <vector> #include <math.h> // Solves for quadratic formula std::vector quadraticCalc(double a, double b, double c); int main(void) { double A = 0, B = 0, Cone, Ctwo; std::vector<double> terms, quadBuff; std::cout << “Enter value for a_(0): “; std::cin >> A; terms.push_back(A); std::cout << std::endl; std::cout << “Enter …

Divide by two to convert decimal to binary

Simple C++ program that converts from decimal to binary by dividing a given number by two repeatedly, saving the remainder to a boolean vector, and then printing the contents of the vector back. #include <iostream> #include <vector> //////////////////////////////////////////////////////////////////////// void printBinary(std::vector passedBool); // std::vector divisionAlgorithm(unsigned long long userInput); // //////////////////////////////////////////////////////////////////////// int …

GCD using Euclidean Algorithm

Given two unsigned long long, x and y, such that x is greater than y… Throughout the algorithm, x = (y * quotient) + remainder void gcdCalc(unsigned long long x, unsigned long long y) { unsigned long long remainder; // While y != 0 while(y) { std::cout

Prime factor finder

#include <iostream> #include <vector> #include <math.h> #include &ltalgorithm> int main(void) { // ull is large data type to input large numbers unsigned long long inputNumb, sieveMax; // for holding found numbers; easy way to sort ascending std::vector&ltunsigned long long&gt foundNumbers; // flag for ending division in prime factorization bool divided; …