44
\$\begingroup\$

An uninteresting number (which I totally didn't make up only for this challenge) is created like this:

  1. Take a positive integer N
  2. Create a new number O by adding the digits of N at the end of N
  3. The final uninteresting number is O*N

For example for N=12:

  1. O = 1212
  2. O*N = 1212 * 12
  3. Final number is 14544

Input

A positive integer N (N > 0) or your language's equivalent. You don't have to catch incorrect input.

Output

The corresponding uninteresting number.

Test cases

  1 -> 11
  2 -> 44
  3 -> 99
 10 -> 10100
174 -> 30306276

Scoring

Shortest Code in Bytes wins.

\$\endgroup\$
19
  • 11
    \$\begingroup\$ There must be a relevant OEIS entry... \$\endgroup\$
    – MKII
    Jul 7, 2016 at 10:52
  • 2
    \$\begingroup\$ @Seims It was a joke, based on the "uninsteresting" name \$\endgroup\$
    – MKII
    Jul 7, 2016 at 11:10
  • 11
    \$\begingroup\$ @MKII my bad, i don't speak joke \$\endgroup\$
    – Seims
    Jul 7, 2016 at 11:13
  • 1
    \$\begingroup\$ Is taking the number as a string argument bending the rules a bit too much? \$\endgroup\$ Jul 7, 2016 at 11:39
  • 1
    \$\begingroup\$ Go ahead, bend the rules! :P \$\endgroup\$
    – Seims
    Jul 7, 2016 at 11:44

77 Answers 77

1 2
3
1
\$\begingroup\$

Desmos, 28 bytes

f(n)=10^{floor(logn)}10nn+nn

Try It On Desmos!

Try It On Desmos! - Prettified

\$\endgroup\$
1
\$\begingroup\$

Ly, 8 bytes

nsS&:Jl*

Try it online!

Ly supports a pretty direct translation of the rules of this challenge...

n         - read in the number
 s        - stash the number
  S       - push the digits of the number onto the stack
   &:     - append the stack to itself
     J    - convert those digits to a number
      l   - restore the original number
       *  - multiple, stack prints as number automatically
\$\endgroup\$
1
\$\begingroup\$

Zsh, 13 bytes

<<<$[$1*$1$1]

Attempt This Online!

\$\endgroup\$
1
\$\begingroup\$

Ruby, 31 26 bytes

-5 bytes thanks to pxeger and Stefan

n=gets;p (n+n).to_i*n.to_i

Attempt This Online!

\$\endgroup\$
3
  • \$\begingroup\$ You can replace puts with just p for -3 bytes \$\endgroup\$
    – pxeger
    Apr 9 at 12:54
  • \$\begingroup\$ you can use just (n+n) instead of the o variable to save another -2 bytes \$\endgroup\$
    – Steffan
    Apr 9 at 15:51
  • \$\begingroup\$ here's 26 bytes \$\endgroup\$
    – Steffan
    Apr 9 at 15:52
1
\$\begingroup\$

Haskell, 23 bytes

A pointfree function which takes and returns an integer.

(*)<*>read.(show<>show)

Attempt This Online!

\$\endgroup\$
0
\$\begingroup\$

ForceLang, 54 bytes, noncompeting

set a io.readnum()
io.write a.mult number.parse a+""+a

Noncompeting, because it requires a language version published after this challenge (containing a patch for a minor parse error relating to the empty string literal).


The original answer, which doesn't require this bugfix (76 bytes):

set a io.readnum()
set b a+string.builder()
io.write a.mult number.parse b+a
\$\endgroup\$
0
\$\begingroup\$

Racket, 74 62 bytes

(λ(n)(*((λ(m)(string->number(string-append m m)))(~a n))n))

I hate the length of built-in function names in Racket sometimes. Other times, I discover a really concisely named version of a function and transform a number->string into ~a.

\$\endgroup\$
0
\$\begingroup\$

C, 52 50 bytes

q;f(char*v){q=atoi(v);return atoi(strcat(v,v))*q;}

Usage

q;f(char*v){q=atoi(v);return atoi(strcat(v,v))*q;}
main(c,v)char**v;{while(*++v)printf("%d\n",f(*v));}

Full Program 75 69 bytes

q;main(c,v)char**v;{q=atoi(*++v);printf("%d",atoi(strcat(*v,*v))*q);}

-2 & -6 thanks to Toby Speight in this comment

\$\endgroup\$
3
  • \$\begingroup\$ Be careful with that main() loop - most implementations don't leave enough space for the strcat() in there. \$\endgroup\$ Jul 7, 2016 at 16:14
  • 1
    \$\begingroup\$ BTW, in the 'full program' version, you don't need to dereference ++v, and you can move the increment over to the next statement: {q=atoi(*++v);... I think that gains you 3 bytes. Moreover strcat() returns the start of the string, so you can use atoi(strcat(v,v))*q and atoi(strcat(*v,*v))*qrespectively. \$\endgroup\$ Jul 7, 2016 at 16:16
  • \$\begingroup\$ True!! I wrote the full program version in a rush... \$\endgroup\$ Jul 7, 2016 at 16:19
0
\$\begingroup\$

Python 3, 43 bytes

x=int(input());print(10**len(str(x))*x+x)*x
\$\endgroup\$
0
\$\begingroup\$

SAS, 32 Bytes

%macro x(a);%eval(&a&a*&a)%mend;

Macro language, so no string/numeric concept. Function style (so this doesn't return the value to the screen, that's your job, this just returns the value).

Examples:

86   %put %x(1);
11
87   %put %x(12);
14544
\$\endgroup\$
0
\$\begingroup\$

Jolf, 4 bytes

Try it here!

*P+§

Explanation

*P+§xxx
*     x   implicit input *
   §x       implicit input as string
  +  x      followed by implicit input
 P         as a number
\$\endgroup\$
0
\$\begingroup\$

Common Lisp (Lispworks), 91 78 77 bytes

(defun f(n)(*(parse-integer(concatenate'string #1=(write-to-string n)#1#))n))
\$\endgroup\$
4
  • \$\begingroup\$ I edited your answer so that it would show up as code. I don't know lisp, so I'm not sure. Is the newline is necessary? \$\endgroup\$
    – DJMcMayhem
    Jul 8, 2016 at 7:20
  • \$\begingroup\$ Is the newline is necessary? not necessary \$\endgroup\$
    – sadfaf
    Jul 8, 2016 at 7:31
  • \$\begingroup\$ I'm not sure, that's why I'm asking you. Will this still run if you combined it into one line? \$\endgroup\$
    – DJMcMayhem
    Jul 8, 2016 at 7:34
  • \$\begingroup\$ yes, lisp separative sign is parentheses or blank space (etc. tabbar\Spacebar) \$\endgroup\$
    – sadfaf
    Jul 8, 2016 at 7:44
0
\$\begingroup\$

T-SQL, 45 bytes

DECLARE @i INT = 12
SELECT CONCAT(@i, @i)*@i
\$\endgroup\$
0
\$\begingroup\$

TI-BASIC, 22 or 24 bytes

Prompt X
X(X+X10^(1+int(log(X

Or, 22 bytes stored as a Y-var (basically a function).

\$\endgroup\$
0
\$\begingroup\$

Python, 46 bytes

i=input("N:")           # Standard input
y=i+(i[-2:])            # Using strip method to take last two chars from input
print(int(y)*int(i))    # Temp convert strings into integers for maths and print the result.
\$\endgroup\$
0
\$\begingroup\$

JavaScript, 25 bytes

Golfed:

_=prompt();alert((_+_)*_)

Ungolfed:

_=prompt();
alert((_+_)*_)

Explanation:

_=prompt();    - set variable to prompt
alert((_+_)*_) - alert output, which is the number plus itself, times itself

This code was originally written by TùxCräftîñg. Their original comment with the code can be found here.

\$\endgroup\$
0
\$\begingroup\$

PHP, 32 bytes

function f($n){print($n.$n)*$n;}

Try it online!

\$\endgroup\$
1 2
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.