Computer Science Question

Watch this thread
JoeStevens123
Badges: 2
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 6 months ago
#1
Just wondering if anyone could help me start this, thank you


Write a programming code to find and print all Palindrome numbers between 1 to 3000.
Print 10 numbers in each line [do not forget to add space between numbers]. To find
a Palindrome number you MUST exactly follow the steps below:
1- For each number, first, calculate the number of digits; You can divide your integer
by 10 and use the integer quotient continuously until you reach zero.
2- Retrieve the first digit from right (last digit when you read your number from left);
you can use modulus operator (%), then make it raised to the correct power of length
e.g., for the first digit it will be raised to power of length minus one (or number of digits
minus one), for the second digit, use number of digits minus two and so on.
3- Repeat step 2, until you have retrieved all digits, then, produce the reverse number.
An example is provided here:
To reverse 125, you need to obtain the length which is 3.
5x103-1+2x103-2+1x103-3 = 521
Once you have calculated the reversed number compare it with the original one and
see whether a Palindrome number has been found.
Do NOT use list, string, list/string operations, any library or recursive function for this
code.
0
reply
mqb2766
Badges: 19
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 6 months ago
#2
Where is the question from and what have you tried?
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Has advance information helped during your exams?

Yes (24)
70.59%
No (7)
20.59%
I didn't use it to prepare (3)
8.82%

Watched Threads

View All