C50

A three-digit number has two properties. The tens-digit and the ones-digit add up to 5. If the number is written with the digits in the reverse order, and then subtracted from the original number,the result is 792. Use a system of equations to find all of the three-digit numbers with these properties.

Let’s write down three-digit number as 100x + 10y + 1z, where x represents hundreds digit y represents tens digit z represents ones digit

Three-digit number has the following properties:

  1. y + z = 5

  2. 100x + 10y + 1z - (100z + 10y + 1x) = 792

99x - 99z = 798 (divide by 99)

x - z = 8

The system of equations is

y + z = 5 (1)

x - z = 8 (2)

or

0x + 1y + 1z = 5 (1)

1x + 0y - 1z = 8 (2)

We assume that

9 >= x > 0 9 >= y => 0 9 >= z => 0

Let analyze the equation #2

x - z = 8

x = 8 + z

9 >= (8 + z) > 0

Let analyze the equation #1

y = 5 - z

9 >= (5 - z) => 0

for(z in 0:9){
  x = 8 + z
  
  if(x > 0 && x <= 9){
    
    y = 5 - z
    if(y >= 0 && y <= 9){
       
      if(as.numeric(paste0(x,y,z)) - as.numeric(paste0(z,y,x)) == 792){
         print(paste0(x,y,z))
       }
     }
   }
}
## [1] "850"
## [1] "941"

There are 2 such numbers - 850 and 941