# Given an int input n, print out n*reversed(n)

Given an integer n, print out n * reversed(n)

reversed(n) is the number you get when you reverse the digits of n.

reverse(512) = 215

reverse(1) = 1

reverse(101) = 101

>>>>>>>>


func(5) = 5*5 = 25

func(12) = 12*21 = 252

func(11) = 11*11 = 121

func(659) = 659*956 = 630004


Shortest code wins!

var QUESTION_ID=144816,OVERRIDE_USER=71625;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• What is the reverse of 100?
– tsh
Oct 10 '17 at 2:33
• 001, but in any case, its fine if you have additional zeros in front Oct 10 '17 at 2:41
• Why downvote? Because this challenge is too trivial (compare to some other challenges, it is not!) or because it is badly-formatted / unclear? Oct 10 '17 at 10:31
• @user202729 I downvoted because I didn't see or anticipate a lot of variety or depth to answers. This question is boring, I tried it. Part of the reason it is boring is because its trivial, which I think is a perfectly just cause to downvote a question on its own. Oct 10 '17 at 19:46

# Pepe, 61 bytes

REeErEEEEErREEEeEerRREEEEEEEREEEEeEeerRREEEEEeEErRREEEEeEReEE


Try it online!

# Burlesque, 5 bytes

J<-|*


Try it online!

J  # Duplicate
<- # Reverse string
|* # string-to-val & multiply


# RProgN 2, 6 bytes

]Ø.in*

]Ø.in*
]       # Duplicate the input to the stack
Ø.     # Append a blank string, stringifying the input.
i    # Reverse it.
n   # Cast to a number.
*  # Multiply with the orignal input, implicitely output.


Try it online!

# Pyth, 4 bytes

*s_


Try it online!

• Wow, I had the same answer Nov 24 '17 at 2:59

# Octave, 66 bytes

n=m=input('');j=0;while(m!=0) j=10*j+rem(m,10);m=fix(m/10);end
n*j


Since Octave doesn't have a function to reverse integers, I had to write one myself. That's what the while loop does. Any help will be much appreciated.

# C# (.NET Core), 60 + 18 bytes

+18 bytes for using System.Linq;.

Reversing strings in C# is a pain.

n=>n*int.Parse(new string(n.ToString().Reverse().ToArray()))


Try it online!

# Husk, 6 bytes

S*(d↔d


Try it online!

Explanation

S*(    Multiply the input with the result of the following function applied to the input
d convert number to list of digits
↔  reverse list
d   interpret list of digits as number


# LOGO, 13 bytes

[?*reverse ?]


Currently there is no TIO for Logo, but you can try it online at http://golf.shinh.org/check.rb . However that's UCBLogo where there is a feature that prints

Thank you for using Logo.
Have a nice day.


on program exit; if this is considered as a function invocation it does not count. (that is, the function does not prints the message)

Usage:

print invoke [?*reverse ?] 123


or

print apply [?*reverse ?] [123]


prints

39483


# Recursiva, 6 bytes

*aI_Va


Try it online!

# Explanation:

*aI_Va
*a      - multiply by a(input)
I     - Integerify
_    - Reverse
V   - Stringify
a  - a (Input)


## Alice, 9 bytes

//.*
oR@i


Try it online!

### Explanation

/    Switch to Ordinal. Move SE.
R.   Reverse and duplicate an implicit empty string. Does nothing.
i    Read all input as a string.
.    Duplicate.
R    Reverse.
/    Switch to Cardinal. Move W.
*    Implicitly convert the two strings to integers and multiply them.
.    Duplicate the result. Irrelevant.
/    Switch to Ordinal. Move NW. Immediately bounces off the wall to move SW instead.
o    Implicitly convert the result back to a string and print it.
/    Switch to Cardinal. Move S.
R    Reverse the other copy of te result. Irrelevant.
/    Switch to Ordinal. Move NE. Immediately bounces off the wall to move SE instead.
@    Terminate the program.


## SAS, 54 bytes

%macro f(n);%put%eval(&n*%sysfunc(reverse(&n)));%mend;


# Tcl, 34 bytes

proc F n {expr $n*[string rev$n]}


Try it online!

# Swift 4, 37 bytes

{$0*Int(String("\($0)".reversed()))!}


Try it here!

Just my mandatory gigantic Swift entry.

# R, 58 bytes

cat((n=scan())*sum(n%/%10^(d=1:nchar(n)-1)%%10*10^rev(d)))


Try it online!

reads from stdin, writes to stdout. n%/%10^(d=1:nchar(n)-1)%%10 is how we get the digits, and reversing them is as simple as taking that vector, multiplying by 10^rev(d), and summing.

# R + stringi, 47 bytes

cat(strtoi(stringi::stri_reverse(n<-scan()))*n)


Try it online!

stringi (not stringr) has a stri_reverse command.

# Pyth, 5 4 bytes

*v_


Try it online!

Explanation:

*v_QQ : accepts a number as input
Q  : represent input as string
_    : reverses string
v     : evaluates the string as a number again
*    Q : multiply by the input
: implicit output
(remove Q's as Pyth adds them for you)


param($a)$a*-join("$a"[-1..-9])  Powershell is more than happy to multiply a number by a valid numerical string which is nice. # Batch, 105 bytes @set c= @set a=%1 :J @set c=%c%%a:~-1% @set a=%a:~0,-1% @if NOT "%a%" == "" goto J @set/ac=%1*%c%  The reverse is performed in a loop which appends the last character @set c=%c%%a:~-1% from the input to c, and then removes the last character from the input string @set a=%a:~0,-1% - rinse and repeat until there are no characters left on the input string. A quick multiplication @set/ac=%1*%c% and done. # QBIC, 12 bytes _F!:$|?a*!A!


## Explanation

   :    Get the input number from the cmd line and assign to 'a'
! $Cast it to string _F | and flip[ that, assigning it into A$
?a*     PRINT 'a' times
!A!    A$cast back to int  # Aceto, 8 bytes rd~isi*p  r reads input d duplicates it ~ reverses the top value i convertes it to an integer s swaps the two top values i convertes the other value to an integer * multiplies the top two p prints the result  Try it online! # Add++, 14 bytes D,f,@,EDE@EdA*  Try it online! ## How it works With example input of 12 D,f,@, - Create a monadic function, f ED - To digits; STACK = [[1 2]] E@ - Reverse; STACK = [[2 1]] Ed - From digits; STACK = [21] A - Argument; STACK = [21 12] * - Product; STACK = [252]  # Excel VBA, 27 22 Bytes Anonymous VBE Immediate window function that takes input from [A1] and outputs to the VBE immediate window ?[A1]*StrReverse([A1])  # Implicit, 5 bytes :ì\ì*  Try it online!  « implicit integer input »; : « duplicate »; ì « convert to string »; \ « reverse »; ì « back to int »; * « multiply »; « implicit integer output »;  ## REXX, 22 bytes arg n say n*reverse(n)  # Jelly, 4 bytes DUV×  Try it online! # Pyt, 3 bytes Đ₫*  Try it online! Đ Duplicate ₫ reverse digits * duh implicit output  # Java 8, 50 bytes n->n*new Long(new StringBuffer(n+"").reverse()+"")  Try it here. Pretty straightforward. • n->: Lambda-function with 64bit-number as input • n+"": Convert the input-number to String • new StringBuffer(...): Convert this String to a StringBuffer • .reverse(): Reverse it • ...+"": Convert the StringBuffer back to String • new Long(...): Convert this String back to a 64bit-number • n*...: Multiply it with the original input, and return it Arithmetic approach would be slightly longer (55 bytes): n->{int i=n,j=0;for(;i>0;i/=10)j=j*10+i%10;return j*n;}  Try it here. Explanation can be found in my C# .NET port. # Gol><>, 21 bytes I:WaSD$|r}l3-Fa*+|+*h


Try it online!

## An example > A million words

I :D WaSD$D| Dr}l3-D Fa*+D| D+*h ^659 [659 659] [659 9 65] [659 9 5 6] [659 9 5 6 0] [659 9 5 6 0] [659 0 6 5 9 2] <- 2 = operations to do [659 0 6 95] [659 0 956] [659 0 956]  Alternate I:WaSD$|~r}l2-Fa*+|*h

I:&WaSD\$|~rlMFa*+|&*h


# APL (Dyalog Unicode), 9 5 bytes

⍎×⍎∘⌽


Try it online!

Tacit prefix function. Takes input as a string of digits.

Thanks to Adám for 4 bytes.

### How it works:

⍎×⍎∘⌽ ⍝ Anonymous, tacit function.
⌽ ⍝ Reverse the input
⍎∘  ⍝ Convert to number
×    ⍝ and multiply
⍎     ⍝ by input converted to number

• ⍎×⍎∘⌽
Feb 22 '18 at 11:36
• @Adám wow, I think this is one of my first APL answers. Thanks for the heads up :) Feb 22 '18 at 13:19
• What's up with the spurious Input ⍵.?
Feb 22 '18 at 13:41
• No idea, probably a hanger-on from an old edit or something :p It's fixed now. Feb 22 '18 at 13:42

# Java 8, 52 bytes

n->new Long(new StringBuilder(n+"").reverse()+"")*n;


Try it online
This will give every linter/IDE/compiler a stroke, but hey, it works

• Hi there. This is the same as my Java answer from 1.5 years ago, except that you won't have to count the trailing semicolon in lambda submissions, and StringBuilder is golfed to StringBuffer. :) Mar 8 '19 at 11:56
• @KevinCruijssen oh nice. Mar 8 '19 at 21:47

# APL(NARS), 8 char, 16 bytes

{⍵×⍎⌽⍕⍵}


test:

  f←{⍵×⍎⌽⍕⍵}
f 23
736
23×32
736
f 11
121