Subtracting 2 reverse numbers - simple algorithm activity
Go to scratch.mit.edu and implement the following algorithm (“recipe”):
Ask the user to give you any 3 digit number, where each digit is different (i.e., no 2 digits are the same). For example: 345.
Make a variable called number and store the user’s answer in this variable.
Hint: use the block
Reverse the digits of this number, to get a second number (in our example: 543).
Hint: use the blocks “letter x of y” and “join x y”:
Save this reversed number in another variable, and make the sprite Say the reversed number (in our example: 543).
Subtract the smaller number from the bigger number, and save the difference (using another variable).
Make your sprite say the difference (in our example the difference is: 198).
Add up the digits of the difference you got in the step above, to get the sum.
Save the sum and make the sprite say the sum
If this sum is equal to, or greater than 10, add the digits of it again, to get a new sum (in our example the sum 1+9+8=18, so you sum again: 1+8=9).
Say the sum
The final sum you will get is: 9. If you didn’t get that, check your program for errors :)
Say the final sum
https://scratch.mit.edu/projects/1370231002