# Intro

Two numbers are a reversed multiple pair if they satisfy the following property:

$$a\cdot b = \operatorname{reversed}( (a-1)\cdot b )$$

Here, $$\\operatorname{reversed}()\$$ means to reverse the digits of a number (e. g 123 becomes 321.)

# Example

$$a=6,\quad b=9,\quad 6\cdot 9=54,\quad 5\cdot 9=45$$

As you can see, $$\45\$$ is the reversed version of $$\54\$$.

Given two integers, $$\a\$$ and $$\b\$$, output if these two numbers is a reversed multiple pair.

# Test Cases

6 9 => True
4 5 => False
3 2178 => True
34 2079 => True
7 8 => False
600 100 => False
46 1089 => True
817 503 => False
6 9009 => True
321 81 => False
10 1089 => False


Shortest code wins!

• Suggest test case: 321 81 => False. An answer checking b for divisibility with 9 will pass all existing test cases but not this one. Jan 29 at 21:43
• Is 10 1089 truthy or falsy? Currently, different answers don't agree on this testcase.
– tsh
Jan 30 at 2:55
• May I assume inputs are positive? Or what is expected output for -5 9?
– tsh
Jan 30 at 6:53
• Shouldn’t 10 1089 be false?
– tsh
Jan 30 at 13:03
• reverse(9*1089)=reverse(9801)=1089≠10890=10*1089
– tsh
Jan 30 at 14:22

# tinylisp, 76 bytes

(load library
(d f(q((a b)(e(to-base 10(*(- a 1)b))(reverse(to-base 10(* a b


Try it online!

# Brachylog, 8 bytes

-₁ʰ×↔~×?


Try it online!

### Explanation

           Input = [A, B]
-₁ʰ        Compute [A-1, B]
×       Compute (A-1) × B
↔      Reverse digits
~×?   It can be unmultiplied into [A,B]


# Python 3, 37 bytes

lambda a,b:str(a*b)==str(~-a*b)[::-1]


Try it online!

# Jelly, 9 bytes

,’$×DU⁼¥/  Try It Online! ,’$×DU⁼¥/    Main Link; dyad accepting a, b
,’$pair: [a, a - 1] × multiply: [ab, (a - 1)b] D to digit list / reduce between the two: U is the reverse of the former ⁼ equal to the latter?  # Jelly, 6 bytes ’×ṚḌ⁼×  A dyadic Link accepting $$\a\$$ and $$\b\$$ that yields 1 if $$\a\times b = \text{reversed}( (a - 1)\times b )\$$, 0 if not. Try it online! Or see the test-suite. ### How? ’×ṚḌ⁼× - Link: a, b ’ - a-1 × - (a-1) times b Ṛ - reverse the digits of (a-1)×b Ḍ - convert back to an integer × - a×b ⁼ - equal?  • how do you code in jelly? Jan 30 at 4:05 • @DialFrost the same way you code in other languages:P Jan 30 at 4:43 • @DialFrost see the tutorial to get started. Jan 30 at 13:19 # APL (Dyalog Unicode), 9 bytes Anonymous tacit infix function, taking $$\a\$$ as left argument and $$\b\$$ as right argument. ×≡∘⌽⍥⍕×-⊢  Try it online! (Uses Extended because TIO hasn't updated to 18.0) × [Does] the product ≡∘ match the… ⌽⍥ reversed, when both are… ⍕ stringified × product - minus ⊢ the right argument[?] # Factor, 47 39 bytes [ over * dup present reverse dec> - = ]  Try it online! Saved 8 bytes thanks to @ovs' observations. ## Explanation Takes input as b a.  ! 9 6 over ! 9 6 9 * ! 9 54 dup ! 9 54 54 present ! 9 54 "54" reverse ! 9 54 "45" dec> ! 9 54 45 - ! 9 9 = ! t  # Python 2, 31 bytes lambda a,b:a*b==a*b-b[::-1]  Using the logic that $$ab = \operatorname{rev}( (a-1)b ) \iff ab = \operatorname{rev}(ab-b)$$ -2 thx to @dingledooper Try it online! ## Other solutions: ### Python 2, 31 bytes lambda a,b:a*b[::-1]==a*b-b  Using the logic that $$\operatorname{rev}(ab) = (a-1)b \iff \operatorname{rev}(ab) = ab-b$$ -2 thx to @dingledooper Try it online! ### Python 2, 34 bytes lambda a,b:a*b-int(a*b[::-1])==b  Using the logic that $$ab - \operatorname{rev}(ab) =b$$ Try it online! ^Credits to @ovs for the equations! • (a-1)*b -> a*b-b Jan 30 at 3:47 • thx @dingledooper! im so dumb i didnt see that Jan 30 at 3:55 # Vyxal, 7 bytes :‹"*÷Ṙ=  Try it Online!  " # Pair the first input with :‹ # Itself decremented * # Multiply both by the second input ÷ # Push both to the stack Ṙ= # Is one reversed equal to the other?  # Charcoal, 13 bytes ＮθＮη⁼×θη⮌×⊖θη  Try it online! Link is to verbose version of code. Outputs a Charcoal boolean, i.e. - for a reversed pair, nothing if not. Explanation: Ｎθ First input as a number Ｎη Second input as a number θ First input × Multiplied by η Second input ⁼ Equals θ First input ⊖ Decremented × Multiplied by η Second input ⮌ Reversed Implicitly print  # Pari/GP, 40 bytes f(a,b)=d=digits;d(a*b)==Vecrev(d(a--*b))  Try it online! # JavaScript (ES6), 41 bytes Expects (a)(b). Returns a Boolean value. a=>b=>[...a*b+''].reverse().join==a*b-b  Try it online! # C (gcc), 55 bytes c;r;f(a,b){for(r=0,c=~-a*b;c;c/=10)r+=9*r+c%10;r-=a*b;}  Try it online! Inputs two integers $$\a\$$ and $$\b\$$. Returns a falsy value if these two numbers are a reversed multiple pair or a truthy value otherwise. # Ruby, 33 bytes ->a,b{"#{a*=b}"==(a-b).digits*''}  Try it online! # Haskell, 43 33 bytes a?b=a*b==read(reverse$show$a*b-b)  Try it online! • I haven't thought reverse was available in prelude, no reason to use foldl(flip(:))""String # Retina 0.8.2, 55 bytes \d+$*
1,
,
1(?=.*,(1+))
$1 , ,$
1+
$.& +(.),\1 , ^,$


Try it online! Link includes test cases. Explanation:

\d+
$*  Convert to unary. 1, ,  Decrement a. 1(?=.*,(1+))$1


Multiply a-1 by b.

,
,$  Add that to b giving (a-1)b,ab. 1+$.&


Convert to decimal.

+(.),\1
,
^,$ Test whether the results are mirror images of each other. # Red, 47 45 bytes func[a b][(to""a * b)= reverse to""a - 1 * b]  Try it online! # BQN, 33 22 Bytes This seems too long. A little better. {(𝕨×𝕩)=•BQN⌽•Fmt𝕩×𝕨-1}  Try it! ¯11 bytes thanks to @Razetime # APL+WIN, 22 20 bytes Prompts for a then b. Minus 2 bytes using rearrangement logic (⍎⌽⍕n-b)=n←(b←⎕)×a←⎕  Try it online! Thanks to Dyalog Classic # Retina, 41 bytes L$.+,
*$'*_,$($^$.(*$'*))*_$'*
^(_+),\1$ Try it online! Link includes test cases. Explanation: Based on @ovs' 05AB1E answer. L$.+,


Match a as $& (Retina ignores the trailing comma when performing arithmetic) and b as $' and replace the whole input with the result.

*$'*_,$($^$.(*$'*))*_$'*


Calculate a*b and also rev(a*b)+b in unary.

^(_+),\1$ See whether they are the same. # Burlesque, 14 bytes Jpdjp^-..*<-==  Try it online! Takes input as array of pairs {a b} J # Duplicate pd # Product of array j # Swap p^ # Push elements to stack (b, a) -. # Decrement .* # Product <- # Reverse digits == # Equal  # GeoGebra, 8677 70 bytes a=6 b=9 s=Text(ab-b) o=Sum(Zip(Take(s,c,c),c,Length(s)…1))==Text(ab)  Try It On GeoGebra! Input is a and b, output is o as true if a and b are a reversed multiple pair, false otherwise. The example input shown in the code is a=6 and b=9, but you can change these values to whatever you want. # J, 20 14 bytes *=|.&.":@(*<:)  -6 bytes, thanks @Jonah Try it online! • Taking args in reverse order, *=|.&.":@(*<:) for 14 bytes: Try it online! Feb 24 at 4:04 # PHP, 79 bytes $a=trim(fgets(STDIN));$b=trim(fgets(STDIN));echo$a*$b==(int)strrev($b*($a-1));  Try it online! With the help of Github Copilot • Instead of all of this, you can just do fn($a,$b)=>$a*$b==+strrev($b*($a-1));. This creates an anonymous function and does the casting to a number in fewer bytes. This syntax was introduced in PHP 8.0. You can see it working for yourself here: sandbox.onlinephpfunctions.com/code/… Jan 31 at 17:41 # MathGolf, 7 bytes (*x¬*=  Try it online. Explanation:  # Duplicate the top two items, using the implicit inputs # STACK: b,a,b,a ( # Decrease the top item # STACK: b,a,b,a-1 * # Multiply the top two together # STACK: b,a,b*(a-1) x # Reverse the top integer # STACK: b,a,reverse(b*(a-1)) ¬ # Reverse rotate the stack: # STACK: reverse(b*a(-1)),b,a * # Multiply the top two again # STACK: reverse(b*a(-1)),b*a = # Check if the two are equal # STACK: reverse(b*a(-1))==b*a # (after which the entire stack joined together is output implicitly)  # T-SQL, 31 bytes Using bitwise operators PRINT-1/~(@*@b^reverse(@b*~-@))  Try it online # Julia 1.0, 56 bytes (a,b,d=digits,s=string)->s(d(a*b))==s(reverse(d(a*b-b)))  Try it online! Pretty straightforward answer, with nothing particularly clever to it (unfortunately). • 33 bytes: a+b="$(a*b)"==reverse("\$(a*b-b)"). Feb 1 at 23:38
• @dingledooper I always forget about the operator trick 🤦 That seems different enough to merit a separate answer! Feb 1 at 23:43

# Ly, 15 bytes

nn&s*SrJlf,*=u;


Try it online!

nn               - read two numbers from STDIN
&s             - save the entries to the backup cell
*            - multiple the two numbers passed in
S           - convert integer to individual digits on stack
r          - reverse stack
J         - re-compose digits on stack into a integer
l        - restore saved numbers
f       - flip top two entries
,      - decrement the top of stack
*     - multiple top two entries
=    - compare the two entries on the stack
u   - print "1|0" from comparison
;  - exit the program