Skip to content

Instantly share code, notes, and snippets.

@DiegoNaterasPonce
Created April 8, 2016 02:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DiegoNaterasPonce/e3d1aa2b4a2d7c887e3fde288b7c7b27 to your computer and use it in GitHub Desktop.
Save DiegoNaterasPonce/e3d1aa2b4a2d7c887e3fde288b7c7b27 to your computer and use it in GitHub Desktop.
#WSQ11 #YoSoy196
#include <iostream>
#include <iomanip>
using namespace std;
int reverse(long num){
long numRev=0;
long sum;
int cont=-1;
do{
sum=num;
numRev=0;
while (num!=0){
numRev = numRev*10+(num%10);
num = num/10;
}
cont++;
num =numRev+sum;
}
while(sum!=numRev && cont!=30);
return cont;
}
int main (){
int LowerBound, UpperBound, palindrome, Palindrome=0, NonLycherels=0, Lycherels=0;
cout << "Tell me the Lower Bound of the sequence\n";
cin >> LowerBound;
cout << "Tell me the Upper Bound of the sequence\n";
cin >> UpperBound;
for(int c=LowerBound; c<UpperBound+1; c++){
reverse(c);
palindrome=reverse(c);
if(palindrome==0){
Palindrome++;
}
else if (palindrome<30){
NonLycherels++;
}
else if (palindrome==30){
Lycherels++;
}
}
cout << "The Palindrome number is: " <<Palindrome<<endl;
cout << "The NonLycherels number is: " <<NonLycherels<<endl;
cout << "The Lycherels number is: " <<Lycherels<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment