Hello, friends. I did the fourth challenge on Project Euler and I'd like to know what I can do to improve the efficiency of my code. Right now it takes 1.562s to run and the source code is as follows: #include #include using namespace std; int Number = 0; int Reversed_Number = 0; int First_Number = 0; int Second_Number = 0; int Product = 0; int Biggest_Palindrome = 0; bool Is_Palindrome = false; string Text_Valued_Number = ""; string Text_Valued_Reversed_Number = ""; void Reverse_Number (int); void For_Loop (int,int); void Check_if_Number_is_a_Palindrome(int,int); void Show_Number(int); void For_Loop(int First_Number, int Second_Number) { for … +0 Hey, guys. Find the sum of all the primes below 2000000. My code: *main.cpp* #include #include #include #include "Sieve.h" using namespace std; typedef unsigned long long int ulli; ulli Sum = 0; ulli Sum_of_Primes(vector, ulli&); ulli Sum_of_Primes(vector Primes, ulli& Sum) { for(ulli a = 2; a < Upper_Limit; a++) { if (Primes[a]) { Sum += a; } } return Sum; } int main() { Find_Primes_until_n(Primes); cout << Sum_of_Primes(Primes,Sum) << endl; return 0; } *Sieve.h* #ifndef SIEVE_H_INCLUDED #define SIEVE_H_INCLUDED using namespace std; #define Upper_Limit 2000000 vector Primes; void Find_Primes_until_n (vector&); void Find_Primes_until_n(vector& Primes) { Primes.resize(Upper_Limit); fill(Primes.begin(),Primes.begin() + Upper_Limit … +0 Hey, guys. A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a² + b² = c². For example, 3² + 4² = 9 + 16 = 25 = 5². There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. #include using namespace std; int a = 0; int b = 0; int c = 0; bool Found = false; int Find_Triplet(int,int,int); int Find_Triplet(int a, int b, int c) { for (int i = 5; i < 1000; i++) { c = i; … +0 Hello, guys. How would I deal with a variable that needs to be biggers than an unsigned long long integer? Thank you. +0 Hello, guys. This challenge asks us to find the 10001-th prime. Here's my code: // A reasonable approximation is to say that the n-th prime is such that p(n) = n*(log n + log*(log n) - 1). // With that in mind, we can say that the 10001-th prime is smaller than 10100*(log 10100 + log(log 10100) - 1), which we can round to 105000. #include #include #define MAX_INTERVAL 105000 using namespace std; int Wanted_Prime = 0; void Show_Prime(int); void Show_Prime(int Wanted_Prime) { cout << "The 10001-th prime is " << Wanted_Prime << endl; } int main() { … +0 Hello, guys. The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product? Here's how I did it: #include #include #include using namespace std; string Grid_of_Numbers = "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121722383113" "62229893423380308135336276614282806444486645238749" "30358907296290491560440772390713810515859307960866" "70172427121883998797908792274921901699720888093776" "65727333001053367881220235421809751254540594752243" "52584907711670556013604839586446706324415722155397" "53697817977846174064955149290862569321978468622482" "83972241375657056057490261407972968652414535100474" "82166370484403199890008895243450658541227588666881" "16427171479924442928230863465674813919123162824586" "17866458359124566529476545682848912883142607690042" "24219022671055626321111109370544217506941658960408" "07198403850962455444362981230987879927244284909188" … +0 Hello, guys. Here's the challenge: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? I wrote my code: #include #include using namespace std; #define MAX_VALUE 2793510720 unsigned int Smallest_Evenly_Divisable = 0; void Show_Number(unsigned int); void Show_Number(unsigned int Smallest_Evenly_Divisable) { cout << "\n\n" << Smallest_Evenly_Divisable << endl; } int main() { unsigned i = 0; for (i = 2520; i < MAX_VALUE; i++) { if ( i % … +0 Hello, guys. I've wrote the following code #include #include #include #include #include #include #include #include #include using namespace std; string Numero_de_Matricula = ""; string Nome = ""; int Numero_de_Materias = 0; int Numero_de_Creditos = 0; vector creditos (10); vector Coeficientes(10); double Coeficiente_Total = 0; bool repetir = false; void ClearScreen(); void Perguntar_Matricula_e_Nome(string,string); void Perguntar_Materias_e_Creditos(); void Perguntar_Coeficientes(int); void Calcular_Media(vector&,int); bool Repetir(bool); void ClearScreen() { HANDLE hStdOut; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD count; DWORD cellCount; COORD homeCoords = { 0, 0 }; hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); if (hStdOut == INVALID_HANDLE_VALUE) return; /* Get the … +0 Hello, guys. I wrote the code to a Quadratic Equations Solver and I'd like for you to run the program and read the source code and give me tips on what I can improve, what is good and what is bad, suggestions, etc. . #include #include #include #include #include #include #include #include using namespace std; float a = 0; float b = 0; float c = 0;float x1 = 0; float x2 = 0; double Delta = 0; bool repetir = false; int i = 0; int Sim_ou_Nao = 0; void Instrucoes(bool); … +0 Hello everyone. I saw a post of one of our friends here about a problem he found of the SPOJ website. So I went there to check it. I found it to be very cool; I started to do the exercises but when I got in the 2nd, a prime number generator, I got stuck. I did made the program and it works as it should, however, it's execution time is too long. So I'm coming here to ask for you to help me make my program more efficient. Here's my source code: #include #include using namespace std; … +0 Hello everyone, my name is Petcheco and I've been coding C and C++ codes for a while. I already came to this website a couple times and I think it's great. It's a pleasure to meet you all and I hope I can assist and be assisted as much as possible, :D. +0

The End.