Project Euler #20: Factorial Digit Sum
n! means n × (n − 1) × … × 3 × 2 × 1 For example, 10! = 10 × 9 × … × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 …
n! means n × (n − 1) × … × 3 × 2 × 1 For example, 10! = 10 × 9 × … × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 …
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, …
In the 20×20 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 …
This is a basic port scanner implementation in Python; it attempts to connect to the given ports of the specified host (all ports, if none indicated), and outputs to a text file and to the console if a given port is open – if it is, it then attempts to …
#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 …
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 …
When I was learning Java, and one of my assignments was to create a program that generated a vertical bar graph of asterisks given user input. Found it so I figured I’d post it -nothing fancy, just something different /////////////////////////////////////////////////////////////////////////////// import java.io.*; import java.util.Scanner; class LabFour { public static void …
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
#include <iostream> #include <vector> #include <math.h> #include <algorithm> 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<unsigned long long> foundNumbers; // flag for ending division in prime factorization bool divided; …
A full adder simulation implementation in C++. It is implemented with a “adder queue” as part of the assignment prerequisites was adding 8 binary strings to a buffer for adding. #include <iostream> #include <vector> #include <algorithm> //////////////////////////////////////////////////////////////////////////////// // Function Prototypes //////////////////////////////////////////////////////////////////////////////// std::string fullAdder(std::vector<std::vector*> adderIn); int userActivity(std::string stringBuff[9], std::vector<std::vector*> &adderInput); void …