Skip to content

Problem #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CPP/04.Longest_palindromic_product.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>
#include <string>

using namespace std;
bool isPalindrome(string x){
if (x.length() == 1){return true;}
if (x.length() == 2){if (x[0] == x[1]) {return true;} return false;}
if (x[0] == x[x.length()-1]){return isPalindrome(x.substr(1,x.length()-2));}
return false;
}

bool isPalindromeHelper(int x){
string numString = to_string(x);
return isPalindrome(numString);
}
int main()
{
int highestPalindrome = 0;
int highesti = 0;
int highestj = 0;
for (int i = 999; i > 99; i--){
for (int j = 999; j > 99; j--){
if (isPalindromeHelper(i*j)){
if (highestPalindrome < i*j){highestPalindrome=i*j; highesti=i; highestj=j;}
}
}
}
cout << endl << "The largest palindrome that is the product of two 3-digit numbers is: " << highestPalindrome << " (" << highesti << " x " << highestj << ")." << endl;
return 0;
}
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,63 @@ Happy Contributing! 😃
| 49 | [Prime permutations](https://projecteuler.net/problem=49) | | | | :white_check_mark: | | | | | | | | |
| 50 | [Consecutive prime sum](https://projecteuler.net/problem=50) | | | | :white_check_mark: | | | :white_check_mark: | | :white_check_mark: | | | |

## Problems
| No | Problem Statement | CPP | Java | JS | Python3 | Kotlin | Dart | C | C# | Go Lang | R | Ruby | Swift |
|---|----|---------|---|------|-------|----|-------------------|-----|------|----|--------|--------|------|

|01 |[Multiples of 3 and 5](https://projecteuler.net/problem=1)| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | |:white_check_mark:| | | |
|02 |[Even Fibonacci numbers](https://projecteuler.net/problem=2)| :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | |:white_check_mark:| | | |
|03| [Largest prime factor](https://projecteuler.net/problem=3)| :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | | |:white_check_mark:| | | |
|04 |[Largest palindrome product](https://projecteuler.net/problem=4)| :white_check_mark: | | | :white_check_mark: | | | | | | | | |
|05 |[Smallest multiple](https://projecteuler.net/problem=5)| | | | :white_check_mark: | | | | | | | | |
|06| [Sum square difference](https://projecteuler.net/problem=6)| | | | :white_check_mark: | | :white_check_mark: | | | | | | |
|07 |[10001st prime](https://projecteuler.net/problem=7)| :white_check_mark: | | | :white_check_mark: | | | | | | | | |
|08| [Largest product in a series](https://projecteuler.net/problem=8)| | | | :white_check_mark: | | | | | | | | |
|09| [Special Pythagorean triplet](https://projecteuler.net/problem=9)| :white_check_mark: | | | :white_check_mark: | | | | | | | | |
|10 |[Summation of primes](https://projecteuler.net/problem=10)| | | | | | | | | | | | |
|11 |[Largest product in a grid](https://projecteuler.net/problem=11)| | | | | | | | | | | | |
|12| [Highly divisible triangular number](https://projecteuler.net/problem=12)| | | | | | | | | | | | |
|13| [Large sum](https://projecteuler.net/problem=13)| | | | | | | | | | | | |
|14| [Longest Collatz sequence](https://projecteuler.net/problem=14)| | | | | | | | | | | | |
|15 |[Lattice paths](https://projecteuler.net/problem=15)| | | | | | | | | | | | |
|16 |[Power digit sum](https://projecteuler.net/problem=16)| | | | :white_check_mark: | | | | | | | | |
|17| [Number letter counts](https://projecteuler.net/problem=17)| | | | | | | | | | | | |
|18 |[Maximum path sum I](https://projecteuler.net/problem=18)| | | | | | | | | | | | |
|19 |[Counting Sundays](https://projecteuler.net/problem=19)| | | | | | | | | | | | |
|20 |[Factorial digit sum](https://projecteuler.net/problem=20)| | | | :white_check_mark: | | | | | | | | |
|21| [Amicable numbers](https://projecteuler.net/problem=21)| | | | | | | | | | | | |
|22 |[Names scores](https://projecteuler.net/problem=22)| | | | | | | | | | | | |
|23| [Non-abundant sums](https://projecteuler.net/problem=23)| | | | | | | | | | | | |
|24| [Lexicographic permutations](https://projecteuler.net/problem=24)| | | | | | | | | | | | |
|25| [1000-digit Fibonacci number](https://projecteuler.net/problem=25)| | | | | | | | | | | | |
|26| [Reciprocal cycles](https://projecteuler.net/problem=26)| | | | | | | | | | | | |
|27| [Quadratic primes](https://projecteuler.net/problem=27)| | | | | | | | | | | | |
|28 |[Number spiral diagonals](https://projecteuler.net/problem=28)| | | | | | | | | | | | |
|29 |[Distinct powers](https://projecteuler.net/problem=29)| | | | | | | | | | | | |
|30| [Digit fifth powers](https://projecteuler.net/problem=30)| | | | | | | | | | | | |
|31| [Coin sums ](https://projecteuler.net/problem=31)| | | | | | | | | | | | |
|32| [Pandigital products](https://projecteuler.net/problem=32)| | | | | | | | | | | | |
|33 |[Digit cancelling fractions](https://projecteuler.net/problem=33)| | | | | | | | | | | | |
|34 |[Digit factorials](https://projecteuler.net/problem=34)| | | | | | | | | | | | |
|35| [Circular primes](https://projecteuler.net/problem=35)| | | | | | | | | | | | |
|36| [Double-base palindromes](https://projecteuler.net/problem=36)| | | | | | | | | | | | |
|37| [Truncatable primes](https://projecteuler.net/problem=37)| | | | | | | | | | | | |
|38 |[Pandigital multiples](https://projecteuler.net/problem=38)| | | | | | | | | | | | |
|39| [Integer right triangles](https://projecteuler.net/problem=39)| | :white_check_mark: | | | | | | | | | | |
|40| [Champernowne's constant](https://projecteuler.net/problem=40)| | | | | | | | | | | | |
|41| [Pandigital prime](https://projecteuler.net/problem=41)| | | | :white_check_mark: | | | | | | | | |
|42 |[Coded triangle numbers](https://projecteuler.net/problem=42)| | | | :white_check_mark: | | | | | | | | |
|43 |[Sub-string divisibility](https://projecteuler.net/problem=43)| | | | | | | | | | | | |
|44 |[Pentagon numbers](https://projecteuler.net/problem=44)| | | | | | | | | | | | |
|45| [Triangular, pentagonal, and hexagonal](https://projecteuler.net/problem=45)| | | | | | | | | | | | |
|46 |[Goldbach's other conjecture](https://projecteuler.net/problem=46)| | | | | | | | | | | | |
|47| [Distinct primes factors](https://projecteuler.net/problem=47)| | | | | | | | | | | | |
|48| [Self powers](https://projecteuler.net/problem=48)| | | | :white_check_mark: | | | | | | | | |
|49| [Prime permutations](https://projecteuler.net/problem=49)| | | | | | | | | | | | |
|50| [Consecutive prime sum](https://projecteuler.net/problem=50)| | | | | | | | | | | | |

---

## Thanks


Expand Down