A palindromic number is a number whose decimal representation reads the same bac
ID: 2884128 • Letter: A
Question
A palindromic number is a number whose decimal representation reads the same backwards and forwards. (For example, 1331, 252, 7777, and 60206 axe all palindromic numbers.) List all the four digit palindromic numbers that are divisible by 18. (that is, all the numbers divisible by 18 whose digits are of the form abba, where a is not zero.) Find the smallest and largest five digit palindromic number that is divisible by 18. (that is, the largest and smallest number divisible by 18 whose digits are of the form abcba, where a is not zero.)Explanation / Answer
1) 2772
4554
6336
8118
/****code for this in c++
#include <bits/stdc++.h>
using namespace std;
int num(int i,int j)
{
int sum=0;
sum=1*i+10*j+100*j+1000*i;
return sum;
}
int main() {
// your code goes here
for(int i=1;i<=9;i++)
{
for(int j=1;j<=9;j++)
{
if(num(i,j)%18==0)
cout<<num(i,j)<<endl;
}
}
return 0;
}
****/
2) smallest -- 21312
largest ---89298
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.