Computer Science Question
Watch this threadPage 1 of 1
Skip to page:
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
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.
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
X
Page 1 of 1
Skip to page:
Quick Reply
Back
to top
to top