text:
Least integer as a product of given factors
There have been a lot of prime-/prime factorization-related challenges recently, so I thought it might be interesting to go the other way.
Given:

a positive integer n, and
a non-empty list of positive integers f

write a full program or a function to find the smallest integer i such that i >= n and i is a product of nonnegative, integer powers of elements in f.
Examples:

Suppose n = 11, f = [2, 3, 5].
The first few products are:
1   = 2^0 * 3^0 * 5^0
2   = 2^1 * 3^0 * 5^0
3   = 2^0 * 3^1 * 5^0
5   = 2^0 * 3^0 * 5^1
4   = 2^2 * 3^0 * 5^0
6   = 2^1 * 3^1 * 5^0
10  = 2^1 * 3^0 * 5^1
9   = 2^0 * 3^2 * 5^0
15  = 2^0 * 3^1 * 5^1
25  = 2^0 * 3^0 * 5^2
8   = 2^3 * 3^0 * 5^0
12  = 2^2 * 3^1 * 5^0 => smallest greater than (or equal to) 11, so we output it.
20  = 2^2 * 3^0 * 5^1
18  = 2^1 * 3^2 * 5^0
30  = 2^1 * 3^1 * 5^1
50  = 2^1 * 3^0 * 5^2
27  = 2^0 * 3^3 * 5^0
45  = 2^0 * 3^2 * 5^1
75  = 2^0 * 3^1 * 5^2
125 = 2^0 * 3^0 * 5^3

Suppose n=14, f=[9, 10, 7].
Again, the first few products:
1 = 7^0 * 9^0 * 10^0
7 = 7^1 * 9^0 * 10^0
9 = 7^0 * 9^1 * 10^0
10 = 7^0 * 9^0 * 10^1
49 = 7^2 * 9^0 * 10^0  => smallest greater than (or equal to) 14, so we output it.
63 = 7^1 * 9^1 * 10^0
70 = 7^1 * 9^0 * 10^1
81 = 7^0 * 9^2 * 10^0
90 = 7^0 * 9^1 * 10^1
100 = 7^0 * 9^0 * 10^2

Test cases:
n, f -> output
10, [2, 3, 5]              -> 10
17, [3, 7]                 -> 21
61, [3,5,2,7]              -> 63
23, [2]                    -> 32
23, [3]                    -> 27
23, [2, 3]                 -> 24
31, [3]                    -> 81
93, [2,2,3]                -> 96
91, [2,4,6]                -> 96
1,  [2,3,5,7,11,13,17,19]  -> 1
151, [20,9,11]             -> 180
11616, [23,32]             -> 12167
11616, [23,32,2,3]         -> 11664 = 2^4 * 3^6
5050, [3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210] -> 5103 = 3^6 * 7
12532159, [57, 34, 12, 21] -> 14183424 = 12^5 * 57

Rules

You may assume that f will contain at least one element, and that all elements of f will be greater than 1.
You may optionally assume that f is sorted in decreasing/increasing order if you would like (but please specify).
You may optionally take the number of elements of f if you would like.
Output as a string is allowed.
This is code-golf, so shortest answer in bytes in each language wins!
Default I/O rules apply, and standard loopholes are forbidden.
Explanations are encouraged.

Husk, 8 bytes
ḟṠ€ȯmΠṖṘ

Extremely slow.
Try it online!
Explanation
ḟṠ€ȯmΠṖṘ  Implicit inputs, say L=[3,4] and n=5.
ḟ         Find the lowest integer k≥n that satisfies:
       Ṙ   Replicate L by k: [3,3,3,3,3,4,4,4,4,4]
      Ṗ    Powerset: [[],[3],[4],..,[3,3,3,3,3,4,4,4,4,4]]
    mΠ     Product of each: [1,3,4,..,248832]
 Ṡ€ȯ       k is in this list.

Wolfram Language (Mathematica), 68 65 62 61 bytes
If[#^#2<=1,1~Max~-Log@#2,Min[#0[#,#2-1,##4],#0[#/#3,##2]#3]]&

Try it online!
How it works
Takes input as [n,k,f1,f2,f3,...,fk] (e.g., [11,3,2,3,5]): the first value is the target n, the second is the number of factors, and all the frctors follow.
The other number-theory challenges recently all folded to fancy built-ins (at the very least, they used FactorInteger) so I thought I'd try something that used only basic tools. This solution basically says that to write n as a product of the factors, we either use the first factor f1 (and recurse on n/f1, then multiply by f1) or don't (and recurse on a shorter list of factors), then take the min.
The recursion bottoms out when the target is less than 1 or when the number of factors is 0, which we check for with #^#2<=1 at once, and then generate 1 in the first case and Infinity in the latter with 1~Max~-Log@#2.
The function gives a whole bunch of warnings (but still works) unless you run it with Quiet, because it eventually recurses to cases where #3 doesn't exist, making the unused second branch of If sad.

-3 bytes: taking the number of factors as input.
-3 bytes thanks to @ngenisis: using ∞.
-1 byte, and no ∞ ambiguity: the #^#2 check.

Very nice! ∞ saves 3 bytes over -Log@0 (doesn't work on TIO, but works fine on desktop Mathematica). Also, Tr[1^{##}]is a byte shorter thanLength@{##}`.

I'm not entirely sure how I feel about using optimizations TIO doesn't like, but sure, I'll add that. And #2 is even shorter than Tr[1^{##}]. :)

Well languages are defined by their interpreter, so using ∞ is valid in Mathematica but not TIO/Wolframscript.

I think you should incude Quiet in your main code.This answer outputs too many wrong messages. At least ask OP if he is ok with it

It seems much the same as ignoring STDERR would be in another language, which is accepted practice.

The ∞ problem appears to be a bug. I'll try to fix that.

Source code containing non-ASCII characters (such as ∞) should work now.

Python 2, 91 88 84 bytes
f=lambda n,l:n<2or any(n%x<1and f(n/x,l)for x in l)
g=lambda n,l:n*f(n,l)or g(n+1,l)

Try it online!
The function f checks recursively if n is a product of powers of elements in l, g is just a wrapper to control the iteration

Python, 55 bytes
f=lambda n,l,x=1:min(f(n,l,x*e)for e in l)if x<n else x

Try it online!
Shamelessly copied Rod's footer script for testing

Jelly, 13 bytes
L⁹ṗ’⁸*P€ḟ⁹Ḷ¤Ṃ

A dyadic link taking the list, f, on the left and the number, n, on the right which yields a number.
Try it online! Golfily inefficient - will time out for inputs with higher n and/or longer f.
How?
We know that the powers of the individual (strictly positive) factors will never need to exceed n-1
...so let's just inspect all the possible ways!
L⁹ṗ’⁸*P€ḟ⁹Ḷ¤Ṃ - Link: list, f; number, n
 ⁹            - chain's right argument, n
L             - length of f
  ṗ           - Cartesian power  ...e.g.: len(f)=2; n=3 -> [[1,1],[1,2],[1,3],[2,1],[2,2],[2,3],[3,1],[3,2],[3,3]]
   ’          - decrement (vectorises)
    ⁸         - chain's left argument, f
     *        - exponentiate (vectorises) - that is [f1^a, f2^b, ...] for each [a, b, ...] in the list formed from the Cartesian power
      P€      - product for €ach - that is f1^a * f2^b * ... for each [a, b, ...] in the list formed from the Cartesian power
           ¤  - nilad followed by link(s) as a nilad:
         ⁹    -   chain's right argument, n
          Ḷ   -   lowered range -> [0,1,2,3,...,n-1]
        ḟ     - filter discard - that is remove values less than n
            Ṃ - minimum

Mathematica, 85 bytes
Min@Select[Flatten[1##&@@(s^#)&/@Tuples[0~Range~⌈Log[Min[s=#],d=#2]⌉,#3]],#>=d&]&

Input

[{list f},n,number of elements of f]
[{57, 34, 12, 21}, 12532159, 4]

{d,s}Min@Select[Flatten[1##&@@(s^#)&/@0~Range~9~Tuples~Tr[1^s]],#>=d&]

@ngenisis what is the symbol that is not displayed? Can you make a TIO link instead?

Never thought I'd see the day where "Mathematica" and "TIO" were used in the same post :P

@Jenny_mathy It's U+F4A1, long name \[Function].

Using 0~Range~9 seems very conservative. Should g[{2,3,5},1001] really skip over 1024 and return 1080? This isn't a particularly large input.

everything is fixed in order to work for any large number. TIO doesn't work anymore

Retina, 76 bytes
\d+
$*
1+;
$&$&
{+`;(1+)(\1)*(?=;.*\b\1\b)
;1$#2$*1
}`(1+);11+;
1$1;1$1;
\G1

Try it online! Link excludes the slowest test cases, but it's still a little slow, so try not to hammer @Dennis's server.

Pyth - 10 bytes
Runs out of memory very quickly.
f}T*My*QTE

Try it online here.
Reasonable answer for 16 bytes: fsm.A}RQ*Md./PTE

Japt, 10 bytes
_k e!øV}aU

Test it online!
Doesn't work on the last test case due to an iteration limit designed to keep the interpreter from running forever (didn't help much here though, as it froze my browser for an hour...)
Explanation
_k e!øV}aU    Implicit: U = input integer, V = array of factors
_      }aU    Starting at U, find the next integer Z where
 k              the factors of Z
   e            are such that every factor
    !øV         is contained in V (e!øV -> eX{VøX}, where VøX means "V contains X").
              Implicit: output result of last expression

Haskell, 46 bytes
This is a port of KSab's excellent Python answer. Thanks to Laikoni for their help in debugging and golfing this answer in the PPCG Haskell chatroom, Of Monads and Men. Golfing suggestions welcome! Try it online!
(#1)
(l#x)n|x<n=minimum[(l#(x*e))n|e<-l]|1>0=x

Jelly, 9 bytes
xŒPP€ḟḶ}Ṃ

O(2n•length(f)) runtime and memory usage make this a theoretical solution.
Try it online!

Mathematica, 73 bytes
1±_=1>0;n_±f_:=Or@@(#∣n&&n/#±f&/@f);n_·f_:=NestWhile[#+1&,n,!#±f&]

Essentially a port of Rod's Python answer. Defines two binary operators ± and ·. n±f returns True if n is a product of elements of f and False otherwise. n·f gives the smallest integer i. If someone can figure out a way to eliminate the divisibility test, I could save 10 bytes by using the ISO 8859-1 encoding.
Explanation
1±_=1>0;                         (* If the first argument is 1, ± gives True. *)
n_±f_:=Or@@(#∣n&&n/#±f&/@f);     (* Recursively defines ±. *)
                                 (* For each element of f, check to see if it divides n. *)
                                 (* For each element # that does, check if n/# is a product of elements of f. *)
n_·f_:=NestWhile[#+1&,n,!#±f&]   (* Starting with n, keep incrementing until we find an i that satisfies i±f. *)

JavaScript (ES6), 53 50 bytes
Saved 3 bytes thanks to @DanielIndie
Takes input in currying syntax (n)(a).
n=>m=a=>(g=k=>k<n?a.map(x=>g(k*x)):k>m?0:m=k)(1)|m

Test cases

let f =

n=>m=a=>(g=k=>k<n?a.map(x=>g(k*x)):k>m?0:m=k)(1)|m

console.log(f(10)([2,3,5]))                // -> 10
console.log(f(17)([3,7]))                  // -> 21
console.log(f(61)([3,5,2,7]))              // -> 63
console.log(f(23)([2]))                    // -> 32
console.log(f(23)([3]))                    // -> 27
console.log(f(23)([2, 3]))                 // -> 24
console.log(f(31)([3]))                    // -> 81
console.log(f(93)([2,2,3]))                // -> 96
console.log(f(91)([2,4,6]))                // -> 96
console.log(f(1,)([2,3,5,7,11,13,17,19]))  // -> 1
console.log(f(151)([20,9,11]))             // -> 180
console.log(f(11616)([23,32]))             // -> 12167
console.log(f(11616)([23,32,2,3]))         // -> 11664 = 2^4 * 3^6
console.log(f(5050)([3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,153,171,190,210])) // -> 5103 = 3^6 * 7
console.log(f(12532159)([57,34,12,21]))    // -> 14183424 = 12^5 * 57

How?
n => a => (                 // given n and a
  g = k =>                  // g = recursive function taking k
    k < n ?                 // if k is less than n:
      a.map(x => g(k * x))  //   recursive calls to g with x * k for each x in a
    :                       // else:
      k > m ?               //   if k is greater than m and m is not set to NaN:
        0                   //     ignore this result
      :                     //   else:
        m = k               //     update m to k
  )(                        // initial call to g with:
    1,                      //   k = 1
    m = +a                  //   m = either NaN or the single integer contained in a
  ) | m                     // return m

n=>m=a=>(g=k=>k<n?a.map(x=>g(k*x)):k>m?0:m=k)(1)|m
m= function always produces false on the first run, so it basically the same as putting +a , this is 51 bytes now

@DanielIndie That's actually 50 bytes. Thanks a lot!

R, 52 bytes
function(n,f)min((y=(x=outer(f,0:n,"^"))%o%x)[y>=n])

Try it online!
It's been 3 weeks, so I thought I'd finally post my own solution. This is a brute force approach.
There is, however, a builtin:
R, 5 bytes
nextn

Try it online!
From the R docs:

nextn returns the smallest integer, greater than or equal to n, which can be obtained as a product of powers of the values contained in factors. nextn is intended to be used to find a suitable length to zero-pad the argument of fft to so that the transform is computed quickly. The default value for factors ensures this.

Some testing revealed a bug in the implementation, however, as the TIO link above shows.
nextn(91,c(2,6)) should return 96, but returns 128 instead. This obviously only occurs when factors are not all relatively prime with one another. Indeed, the C code underlying it reveals that nextn greedily tries to divide each factor in turn until 1 is reached:
static Rboolean ok_n(int n, int *f, int nf)
{
    int i;
    for (i = 0; i < nf; i++) {
    while(n % f[i] == 0) {
        if ((n = n / f[i]) == 1)
        return TRUE;
    }
    }
    return n == 1;
}
static int nextn0(int n, int *f, int nf)
{
    while(!ok_n(n, f, nf))
    n++;
    return n;
}
This can be solved by taking input in decreasing order.


text:
A train crosses a labeled bridge
Consider a bridge of length B formed by tiles labeled with the digits of the positive integers concatenated. For example, if B was 41, then it would look like this:

-----------------------------------------
12345678910111213141516171819202122232425

Now imagine a train of length T crossing the bridge. The leftmost point of the train starts at position X (1-indexed). To get a better understanding of the problem, let's make a scheme of the event, with B = 41, T = 10, X = 10. The train is drawn using equal signs (=) and lines:

         __________
         |========|
         |========|
-----------------------------------------
12345678910111213141516171819202122232425

The train can advance, at each step, by sum of the unique tiles it is located on. For example, the tiles the train stands on above are: [1, 0, 1, 1, 1, 2, 1, 3, 1, 4], the unique (deduplicated) tiles are: [1, 0, 2, 3, 4], and their sum is 10. Hence, the train can advance by 10 tiles. We should draw it again and repeat the process until the leftmost point of the train has passed the last tile:

                   __________
                   |========|
                   |========|
-----------------------------------------
12345678910111213141516171819202122232425

Sum of unique tiles: 1 + 5 + 6 + 7 + 8 + 9 = 36. The train advances by 36 tiles...

                                                       __________
                                                       |========|
                                                       |========|
-----------------------------------------
12345678910111213141516171819202122232425

The train obviously crossed the bridge completely, so we should stop now.

Since the people inside are bored, they count the tiles the train has advanced each time. In this specific case, 10 and 36. Summing everything up, the train has moved 46 before it passed the bridge.

Task
Given three positive integers, B (the bridge length), T (the train length) and X (the starting position, 1-indexed), your task is to determine how many tiles the train has moved until it crossed the bridge following the rules above.

You can assume that:

B is higher than T.
X is lower than B.
T is at least 2.
The train eventually crosses the bridge.

All our standard rules apply.
This is code-golf, so the shortest code in bytes wins!

Test cases

Input ([B, T, X]) -> Output

[41, 10, 10] -> 46
[40, 10, 10] -> 46
[30, 4, 16] -> 24
[50, 6, 11] -> 50

Another worked example for the last test case:

The bridge is of length 50, the train 6, and the starting position is 11.

          ______
          |====|
          |====|
--------------------------------------------------
12345678910111213141516171819202122232425262728293

Unique tiles: [0, 1, 2]. Sum: 3.

             ______
             |====|
             |====|
--------------------------------------------------
12345678910111213141516171819202122232425262728293

Unique tiles: [1, 2, 3, 4]. Sum: 10.

                       ______
                       |====|
                       |====|
--------------------------------------------------
12345678910111213141516171819202122232425262728293

Unique tiles: [1, 7, 8, 9]. Sum: 25.

                                                ______
                                                |====|
                                                |====|
--------------------------------------------------
12345678910111213141516171819202122232425262728293

Unique tiles: [9, 3]. Sum: 12.
                                                            ______
                                                            |====|
                                                            |====|
--------------------------------------------------
12345678910111213141516171819202122232425262728293

Train exists the bridge. Total sum: 3 + 10 + 25 + 12 = 50.

Can we assume the train does cross the bridge eventually? For inputs like (200, 2, 169), the train gets stuck on the 00 in …9899100101102….

@Lynn A little late, yes, you can.

Husk, 20 bytes
ṁ←U¡S↓←moΣuX_⁰↓Θ↑ṁdN

Try it online!
Takes three arguments in order T, B, X.
Explanation
ṁ←U¡S↓←moΣuX_⁰↓Θ↑ṁdN
                 ṁdN    Build the list of digits of natural numbers
              ↓Θ↑       Take the first B digits, add a 0 in front
                        then drop the first X digits
           X_⁰          Get all sublists of length T
       moΣu             Map the sum of unique values of each sublist

   ¡S↓←                 Repeatedly drop as many elements from the start of the list as the
                        first element of the list says;
                        keep all partial results in an infinite list.

  U                     Take elements until the first repeated one
                        (drops tail of infinite empty lists)

ṁ←                      Sum the first elements of each remaining sublist

Python 2, 110 105 104 103 100 97 96 bytes

Saved five bytes thanks to Mr. Xcoder; removed unnecessary assignment, moved negation into available whitespace.
Saved a byte thanks to Mr. Xcoder; golfed [~-x:x+~-t] to [~-x:][:t].
Saved a byte; golfed ...range(1,-~b)))[:b] to ...range(b)))[1:-~b].
Saved three bytes; golfed [1:-~b][~-x:] to [:-~b][x:].
Saved three bytes; golfed [:-~b][x:] to [x:-~b].
Saved a byte thanks to Lynn; golfing the while loop to an exec statement.

b,t,x=input();S=x;exec"x+=sum(set(map(int,''.join(map(str,range(b)))[x:-~b][:t])));"*b;print-S+x

Try it online!

An alternative 105 bytes long solution.

104 bytes. [~-x:x+~-t] can be replaced by [x-1:][:t]

exec"x+=sum(set(map(int,''.join(map(str,range(b)))[x:-~b][:t])));"*b works for 96. (The train will never take more than b steps to leave the bridge, and that whole operation will amount to x+=0 over and over once it’s left.)

Haskell, 106 102 bytes
import Data.List
(b#t)x|x>b=0|y<-sum[read[c]|c<-nub$take t$drop(x-1)$take b$show=<<[1..]]=y+(b#t)(x+y)

Try it online!
(b#t)x
   |x>b=0                 -- if the train has left the bridge, return 0
   |y<-sum[   ]           -- else let y be the sum of
      read[c]|c<-         -- the digits c where c comes from
        nub               -- the uniquified list of
            show=<<[1..]] -- starting with the digits of all integers concatenated
          take b          -- taking b digits (length of bridge)
         drop(x-1)        -- dropping the part before the train
        take t            -- take the digits under the train
     =y+(b#t)(x+y)        -- return y plus a recursive call with the train advanced

R, 123 bytes
function(B,T,X){s=substring
while(X<B){F=F+(S=sum(unique(strtoi(s(s(paste(1:B,collapse=''),1,B),K<-X+1:T-1,K)))))
X=X+S}
F}

Just implements the described algorithm.
R is quite terrible at strings.
function(B,T,X){
 s <- substring                         # alias
 b <- s(paste(1:B,collapse=''),1,B)     # bridge characters
 while(X<B){                            # until we crossed the bridge
  K <- X+1:T-1                          # indices of the characters
  S <- s(b,K,K)                         # the characters from b
  S <- sum(unique(strtoi(S)))           # sum
  F <- F + S                            # F defaults to 0 at the beginning
  X <- X + S                            # advance the train
 }
 F                                      # number of steps, returned
}

Try it online!

Jelly,  22  21 bytes
ḣ⁵QS
RDẎḣ⁸ṫṫÇ‘$$ÐĿÇ€S

A full program taking three arguments - the order is B, X, T - which prints the result.
Try it online!
How?
ḣ⁵QS - Link 1, calculate next jump: list of digits, bridge under and beyond train's left
 ⁵   - program's fifth command line argument (3rd input) = T (train length)
ḣ    - head to index (get the digits of the tiles under the train)
  Q  - de-duplicate
   S - sum

RDẎḣ⁸ṫṫÇ‘$$ÐĿÇ€S - Main link: number, B (bridge length); number, X (starting position)
R                - range(B) = [1,2,3,...,B-1,B]
 D               - to decimal list (vectorises) = [[1],[2],[3],...,[digits of B-1],[digits of B]]
  Ẏ              - tighten (flatten by one) = [1,2,3,...,digits of B-1,digits of B]
    ⁸            - chain's left argument, B
   ḣ             - head to index (truncate to only the bridge's digits)
     ṫ           - tail from index (implicit X) (truncate from the train's left)
           ÐĿ    - loop, collecting results, until no more change occurs:
          $      -   last two links as a monad:
         $       -     last two links as a monad:
       Ç         -       call last link (1) as a monad (get next jump)
        ‘        -       increment
      ṫ          -     tail from that index (remove the track to the left after train jumps)
             Ç€  - call last link (1) as a monad for €ach (gets the jump sizes taken again)
               S - sum
                 - implicit print

JavaScript (ES6), 117 bytes
f=(B,T,X,g=b=>b?g(b-1)+b:'',o=0)=>X<B?[...g(B).substr(X-1,T)].map((e,i,a)=>o+=i+X>B|a[-e]?0:a[-e]=+e)&&o+f(B,T,X+o):0

A pair of recursive functions:

f() sums the train's moves.
g() creates the string of numbers.

Less golfed:
f=
(B,T,X,
 g=b=>b?g(b-1)+b:'',                       //creates the string of numbers
 o=0                                       //sum of tiles the train sits on
)=>
  X<B?                                     //if we're not past the bridge:
      [...g(B).substr(X - 1,T)].map(       //  grab the tiles we're sitting on
        (e,i,a)=>o += i + X > B |          //  if we've passed the bridge,
                      a[-e] ? 0 :          //  ... or we've seen this tile before, add 0 to o
                              a[-e] = +e   //  else store this tile and add its value to o
      ) &&
      o + f(B,T,X+o) :                     //recurse
  0

f=(B,T,X,g=b=>b?g(b-1)+b:'',o=0)=>X<B?[...g(B).substr(X-1,T)].map((e,i,a)=>o+=i+X>B|a[-e]?0:a[-e]=+e)&&o+f(B,T,X+o):0

console.log(f(41, 10, 10));  //46
console.log(f(40, 10, 10));  //46
console.log(f(30, 4, 16));   //24
console.log(f(50, 6, 11));   //50

PHP >= 7.1, 153 bytes
<?$s=substr;[,$p,$q,$r]=$argv;while($i<$p)$a.=++$i;$a=$s($a,0,$p);;while($r<$p){$x+=$n=array_sum(array_unique(str_split($s($a,$r-1,$q))));$r+=$n;}echo$x;

Try it online!
To make it compatible with lower versions of PHP, change [,$p,$q,$r]= to list(,$p,$q,$r)= (+4 bytes).
<?
[,$bridgelen,$trainlen,$position] = $argv;                  // grab input
while($i<$bridgelen)                                        // until the bridge is long enough...
  $bridgestr .= ++$i;                                       // add to the bridge
$bridgestr = substr($bridgestr,0,$bridgelen);               // cut the bridge down to size (if it splits mid-number)
while($position<$bridgelen){                                // while we are still on the bridge...
  $currtiles =                                              // set current tiles crossed to the...
    array_sum(                                              // sum of tiles...
      array_unique(                                         // uniquely...
        str_split(substr($bridgestr,$position-1,$trainlen)) // under the train
      )
    )
  ;
  $totaltiles += $currtiles;                                // increment total tiles crossed
  $position += $currtiles;                                  // set new position
}
echo $totaltiles;                                           // echo total tiles crossed

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
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!
Leaderboard

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="
"+e.body.replace(OVERRIDE_REG,"")+"
")});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;/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}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

What is the reverse of 100?

001, but in any case, its fine if you have additional zeros in front

Why downvote? Because this challenge is too trivial (compare to some other challenges, it is not!) or because it is badly-formatted / unclear?

@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.

What if the input is negative?

05AB1E, 2 bytes
R*

Try it online!
In 05AB1E, integers and strings are treated as equivalent types, so reversal (R) converts to string and reverses, whilst multiplication (*) treats the reverse and the input as integers.

Â* is valid too :D.

JavaScript (SpiderMonkey), 45 35 33 28 bytes
n=>n*[...n].reverse().join``

Try it online!

Saved 2 bytes thanks to dennis
Saved 8 bytes thanks to kamoroso94
Saved 2 bytes thanks to ATaco
Saved 5 bytes thanks to Shaggy

Welcome to PPCG! You don't have to count f=; anonymous functions are allowed by default.

Switch out (n+"").split("") for [...(n+"")] to save a few bytes.  You don't need the unary plus, and the parentheses around the reversed string are extraneous.  All in all, that saves you 10 bytes.

You can replace .join("") with .join\`` to save 2 bytes.

Save 5 bytes by taking input as a string: https://tio.run/##BcFRCoAgDADQu/ilQYP6t4tEoNgMzTZxIXR6ey/77iW0VN9ZajqxPUw3fiPaQXajaQcAOqBhxyaoDWRO5NwITMIFofClo1bLqowZPw

Jelly, 3 bytes
×ṚḌ

I'm new to Jelly, so please let me know if there is a way to do this in 1 or 2 bytes!
Try it online!
Explanation
×ṚḌ    (Input: 12)

 Ṛ     Reversed decimal digits (Stack: [2, 1])
×      Multiply by input       (Stack: [24, 12])
  Ḍ    Convert to decimal      (Stack: 252)
       Implicit print

Actually ṚḌ× would be a better version. Of course this would still work, due to how bases work.

@EriktheOutgolfer I originally wrote that first, but moved the × for fanciness ;)

Ruby, 25 24 bytes
->n{n*eval(n.digits*'')}

Try It Online!.
Integer#digits returns a list of reversed digits, so further reversing is not necessary.
Thanks to @benj2240 for golfing a byte!

You can save a byte with eval

@benj2240 thanks! :)

The eval route doesn't actually work, as it will cause the program to fail on 900 with error Invalid octal digit (SyntaxError) instead of returning the expected 8100...

Ohm v2, 2 bytes
œΠ

Try it online!
Explanation:
œΠ   Main wire, arguments: n

œ    Pushes [n, n.reverse]
 Π   Multiplies that array together
     Implicit output

stays on the phone for 4 months :P

You must be put on hold for a long time for there to be no explanation

@MilkyWay90 We've all been stuck on hold for a year and a half before, right?

@NickClifford Not all of us have

ARBLE, 12 bytes
Takes input as an int.
a*reverse(a)

Try it online!

Thats why I said integer input ;), does int still work?

@KSplitX Oh, I didn't notice that. I'd think that restriction a bit unnecessary, but it's up to you.

@KSplitX Fixed.

Should use n * reverse(n) so it matches the question's specification word for word (Given an integer n, print out n * reversed(n))

Perl 5, 11 + 1 (-p) = 12 bytes
$_*=reverse

Try it online!

Command-line flags are free now!

Python 3, 35 28 bytes
lambda m:m*int(str(m)[::-1])

Try it online!
Saved 7 bytes by fixing a bug pointed out by Dennis.

Nah its clear, you convert to string, the [::-1] reverses it, then we eval xD

This doesn't work for input 80, as 08 is an invalid (octal) literal.

Saved 7 bytes by fixing a bug Don't you just love it when that happens...

Haskell, 27 23 bytes
4 bytes saved thanks to Lynn and Laikoni
(*)=<<read.reverse.show

Try it online!

23 bytes without import: Try it online!

With Control.Monad it is also 23 bytes: ap(*)$read.reverse.show.

No need for Control.Monad. (*)=<<read.reverse.show works fine.

@Lynn Thanks! I feel like I should have seen that.

J, 7 bytes
*|.&.":

Try it online!
Couldn't think of a shorter way, though I feel like this is pretty elegant.
Explanation
*|.&.":
   &.":  Convert to string, apply next function, then undo conversion
 |.      Reverse
*        Multiply by input

bash, 52 48 bytes
for((i=n=$1;r=r*10+i%10*n,i/=10;));{ :;};echo $r

You can replace do...done with curly braces to save some bytes: Try it online!. This is from the tips for Bash post.

thank-you, I'm glad to learn it, I had never seen this syntax, updating my post

Isn’t that shellshock?

C# .NET, 55 bytes
n=>{int i=n,j=0;for(;i>0;i/=10)j=j*10+i%10;return n*j;}

Explanation:
Try it here.
n=>{           // Method with integer as both parameter and return-type
  int i=n,     //  Integer `i` (starting at the input)
      j=0;     //  Integer `j` (starting at 0)
  for(;i>0;    //  Loop as long as `i` is not 0
      i/=10)   //    After every iteration: Remove the last digit of `i`
    j=j*10     //   Add a trailing zero to `j`,
      +i%10;   //   and then sum this new `j` with the last digit of `i`
               //  End of loop (implicit / single-line body)
  return n*j;  //  Return the input multiplied with `j`
}              // End of method

Perl 6, 10 bytes
{$_*.flip}

Try it
Expanded
{       # bare block lambda with implicit parameter $_
  $_
  *
  .flip # implicit method call on $_
}

Bash + GNU utilities, 18
bc<<<$1*`rev<<<$1`

Try it online.

Batch, 150 125 121 bytes (+ 5 bytes? cmd/q)
set l=%1
set n=0
set r=
:L
call set t=%%l:~%n%,1%%%
set/an+=1
if [%t%] neq [] set r=%t%%r%&goto L
set/ar=%r%*%l%
echo %r%

Saved 25 bytes thanks to user202729!
Saved 4 bytes thanks to Matheus Avellar!

97 bytes

Or, 87 bytes

Isn't this Batch, not Bash? The TIO for bash does not work for this.

Yes, yes it is; sorry about that

You can inline that if to be at 121 bytes:  if [%t%] neq [] set r=%t%%r%&goto L. However, I think you gotta include 1 byte for the /Q flag passed tocmd so it runs with implicit @echo off

Batch, 87 bytes
@set s=%1
@set r=
:l
@set/ar=r*10+s%%10,s/=10
@if %s% gtr 0 goto l
@cmd/cset/a%1*r

Need to take the arithmetic route here as string reversal fails for some numbers such as 80.

C (gcc), 49 bytes
i,a;f(n){for(i=0,a=n;a>0;a/=10)i=i*10+a%10;n*=i;}

Try it online!

Suggest replacing a>0 with just a

LISP, 91 64 bytes
     (defun R (N)(defvar M (write-to-string N)) (parse-integer (reverse M))) (write (* x (R x)))
(defun R(N)(write(* N(parse-integer(reverse(write-to-string N))))))

Where x N is your integer you want to work with, of course.
I'm pretty new to programming, but I've found that trying these Code Golf problems has been nice practice. Is there something I'm missing that could help with this?
EDIT: Thanks to some tips from ceilingcat, I was able to shave off a few bytes. Old program preserved in strikethrough for reference.

Welcome to Code Golf! You can eliminate some whitespace and maybe ditch a variable assignment. Also, by convention you may be able to just return the output instead of (write ...)

You can save a byte using a lambda instead of defun. Also, read tips for golfing in lisp

><>, 41 39 Bytes
:&>:a%:}-\
/~\?)0:,a/
>l1-?\&*n;
\ +*a/

How it works:
:&

Assume input has been pushed to the stack (https://codegolf.meta.stackexchange.com/a/8493/76025). Duplicate it and store a copy in the register.
   >:a%:}-\
   \?)0:,a/

Converts this to its individual digits, leaving them on the stack.
/~
>l1-?\
\ +*a/

The top value will always be a zero due to the number-to-digit conversion process; drop it from the stack. Now, while the length is >1, multiply the first item by ten and add it to the item below it. This results in the number reversed.
      &*n;

Multiply the original number by the reverse, print the answer, and stop.

33 bytes

Leaf Lang, 41 bytes
Note: The interpreter does not have a stable release. If I introduce a breaking change I will update this post.
import"string.lf"argv:o o reverse o*print

Explained:
import "string.lf" - import stdlib's string.lf
argv               - push all of argv onto stack
:o                 - set o to top value from stack (pops top)
o                  - push o to top of stack
reverse            - reverse the string
o                  - push o to top of stack
*                  - leaf lang will implicitly convert strings to numbers when applicable
print              - print top value of stack with no newline

Ungolfed:
import "string.lf"
argv : num
num reverse num *
print

Vyxal, 2 bytes
Ṙ*

Try it online, or verify all test cases.

Julia, 28 bytes
~n=parse(Int,reverse("$n"))n

Attempt This Online!

Mathematica, 19 bytes
# IntegerReverse@#&

Takes an integer input.

cQuents 0, 8 bytes
#|1:A\rA

Try it online!
Explanation
#|1:      Output first term in sequence
    A\rA  Each term in the sequence equals:
           A * \reverse(A)

PHP, 23+1 bytes
<?=$argn*strrev($argn);

Save to file and run as pipe with -nF.

Ly, 7 bytes
nsSrJl*

Try it online!

Casio-Basic (fx-CP400), 44 bytes
ExpToStr n,a
StrInv a,a
Print n*strToExp(a)

There's no built-in for reversing an integer, but there is one for reversing a string.
ExpToStr n,a turns n into a string and stores it in a, then StrInv a,a overwrites a with the reversed version of itself. The last line turns a into a number, and prints n*a.
43 bytes for the code, +1 to input n into the parameters box.

Japt, 2 bytes
Takes input as a string, outputs an integer.
*w

Try it

Wow, I thought it would have to be 4 bytes at least... I suppose it's only 3 even if taking input as an integer *sw

@ETHproductions: yeah, that's what I had originally.

MATLAB/Octave, 33 31 bytes
@(n)str2num(flip(int2str(n)))*n

Try it online!
Octave/MATLAB anonymous function. This is a pretty naïve approach - converts the integer to a string, flips the string, converts the result back to an integer and multiplies it by the original.

Save 2 bytes by using flip instead of fliplr.

Python 2, 25 bytes
lambda n:n*int(`n`[::-1])

Try it online!

Lua, 42 bytes
function f(n)print(n*(""..n):reverse())end

Try it online!

MATL, 5 bytes
VPUG*

Try it online!
Explanation: V converts to string, P flips, U converts back to numeric, G copies the original input again, and * multiplies them together.

><>, 33 bytes
:&v>&*nr
a,>:a(?^:a%:@-
2(?va*+>l

Try it online!

Runic Enchantments, 11 10 bytes
i:0qr͍n*@

Try it online!
Takes input, duplicates it, coerces one copy to a string, reverses it, coerces it back to a numerical value, multiplies, and outputs the result.
0q performs the coercion to a string by concatenating a zero onto the end. There is no explicit ToString() operator, so this is the shortest method in this specific case where the 0 swapped to the beginning doesn't alter the resulting numerical value. Thanks to ASCII-only for this -1 byte.

10

@ASCII-only Fair enough. I end up fiddling with most of these at work and don't always revisit when I go to post them at home.

Pepe, 61 bytes
REeErEEEEErREEEeEerRREEEEEEEREEEEeEeerRREEEEEeEErRREEEEeEReEE

Try it online!

Burlesque, 5 bytes
J<-|*

Try it online!
J  # Duplicate
<- # Reverse string
|* # string-to-val & multiply

JavaScript, 72 bytes
Doesn't use strings. At all.
-10 by steffan
n=>(a=[],r=n=>(n>9&&r(n/10|0),a=[n%10,...a]))(n).reduce((a,v)=>a*10+v)*n

You can replace Math.floor(n/10) with n/10|0.

seems I have a lot to learn...

Desmos, 97 bytes,
f=\left\{x>0:floor(log(x))+1,0\right\}
g(x)=x∑_{n=0}^f10^{f-n}floor(mod(\frac{x}{10^{n-1}},10))

Try it on Desmos.
Not sure if this is legal as a Desmos answer, uses the fact that variables can be defined in terms of x, but functions of x can use those variables as functions? I'm not sure what actually is happening, but it seems to be... working. If I'm not allowed to use that, change f= to f(x)= for +3 bytes
Only works for nonnegative integers, which I think is fine since OP doesn't include any test cases for them, and they're not well defined for this problem (what is -1 backwards? 1-? That's not a number IMO). If I'm allowed to assume positive integers, the first line can become
f=floor(log(x))+1

for -21 bytes. Very nice, but the challenge says "integers", so it's iffy.
In general though, I know this is further golfable but I tried some of the Desmos tips and I must be doing something wrong because they weren't working. I'll come back and golf this eventually.
Code breakdown:
f=\left\{x>0:floor(log(x))+1,0\right\} definition of... function(?) f
f=                                     define f as
         x>0:                          if x is positive
             floor(log(x))+1             length(x)
                            ,0         else 0
                                       i dont remember why but this works to make g(0)=0

g(x)=x∑_{n=0}^f10^{f-n}floor(mod(\frac{x}{10^{n-1}},10)) definition of main function
g(x)=                                                    define g(x) as
     x                                                   x times
      ∑                                                  the sum of
       _{n=0}^f                                          for each n from 0 to f(x)
               10^{f-n}                                    10^(f-n) times
                       floor(mod(\frac{x}{10^{n-1}},10))   the nth digit from the right of x
                                                         essentially: sum of
                                                           (nth digit of x)
                                                           multiplied by
                                                           (place value of
                                                           (length(x)-n)th digit of x
                                                         aka: reverse(x)

66 bytes. Btw, variables that are defined in terms of function arguments are called wackscope variables, and is allowed and golfier to use them. In fact, one of my tips goes over this exact thing.

Julia, 33 32 bytes
~n=foldl((x,y)->10x+y,digits(n))n

1 more byte saved by @MarcMush:

a^b=10a+b
~n=foldl(^,digits(n))n

Attempt This Online!

-1 byte https://ato.pxeger.com/run?1=m700qzQnM3HBgqWlJWm6FjcVEuOSbA0NErWTuOrybNPyc1JyNOJ0UjLTM0uKNfI0NfOg6oLT8osUNPJ0UisKUpNLUlM0bTU0THWMTDV1NAyNgLQRiGGoY2hkCGSYmVrqmBkbGBiYaGpycRYUZeaV5ORpAM23hWvnSs1LgRgNcwoA

CJam, 8 bytes
l_W%i\i*

Try it online!

-2:
Try it online!

brev, 28 bytes
(fn(*((as-list reverse)x)x))

Crashes on negative

Pip, 4 bytes
a*Ra

Try It Online!

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!

PowerShell, 31 Bytes
param($a)$a*-join("$a"[-1..-9])

Powershell is more than happy to multiply a number by a valid numerical string which is nice.

Implicit, 5 bytes
:ì\ì*

Try it online!
        « implicit integer input   »;
:       « duplicate                »;
 ì      « convert to string        »;
  \     « reverse                  »;
   ì    « back to int              »;
    *   « multiply                 »;
        « implicit integer output  »;

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.

Pyth, 4 bytes
*s_`

Try it online!

Wow, I had the same answer

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.

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

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!

Arithmetic approach is shorter in C# .NET: n=>{int i=n,j=0;for(;i>0;i/=10)j=j*10+i%10;return n*j;} (55 bytes)

@KevinCruijssen Go ahead, post it as your own answer, it's a completely different approach. :)

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)

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.

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.

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])

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)

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!

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

⍎×⍎∘⌽

@Adám wow, I think this is one of my first APL answers. Thanks for the heads up :)

What's up with the spurious Input ⍵.?

No idea, probably a hanger-on from an old edit or something :p It's fixed now.

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]

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

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

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. :)

@KevinCruijssen oh nice.

APL(NARS), 8 char, 16 bytes
{⍵×⍎⌽⍕⍵}

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

Keg, 3 bytes
:⑶*

Try it online!
A port of the 05AB1E answer but longer.

Prolog (SWI), 47 bytes
N-O:-name(N,C),reverse(R,C),name(I,R),O is I*N.

Try it online!
-16 thanks to Jo King

Both number_codes can be replaced by name

MathGolf, 2 bytes
x*

Try it online.
Explanation:
x   # Reverse the (implicit) input-integer
 *  # Multiply it by the (implicit) input-integer
    # (after which the entire stack is output implicitly as result)

Fig, \$2\log_{256}(96)\approx\$ 1.646 bytes
*$

See the README to see how to run this
*$ # Full program
*  # Multiply
 $ # The reversed number
   # By the implicit input

CellTail, 89 bytes
1,_,_:1,N,N;N,(a,0,c),_:N,a*c,1;N,(a,b,c),_:N,(a,b/10,c*10+b%10),1;N,a&N..,N:N,(a,a,0),1;

Try the demo
CellTail has no way to turn a number into a string so we have to use modulus and integer division. Uses the cell to the right to provide recursion resistance.

J-uby, 11 bytes
:*%(S|:~|Z)

Attempt This Online!
Explanation
:* % (S | :~ | Z)

      S | :~ | Z   # Convert input to string, reverse, then convert to int
:* % (          )  # Multiply by input

```

GolfScript, 7 bytes
.`-1%~*

Try it online!
Link includes test cases
Explanation
code    # explanation                             | stack
.`-1%~* # function which takes an input integer n | n
.       # duplicate n                             | n n
 `      # stringify                               | n str(n)
  -1%   # reverse                                 | n reverse(str(n))
     ~  # eval                                    | n reverse(n)
      * # multiply                                | n*reverse(n)

SNOBOL4 (CSNOBOL4), 36 bytes
	OUTPUT =(I =INPUT) * REVERSE(I)
END

Try it online!

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
26 Singers, 26 Letters
According to RollingStone, below are the 26 greatest singers of all time:
Aretha Franklin         Al Green
Ray Charles             Robert Plant
Elvis Presley           Mick Jagger
Sam Cooke               Tina Turner
John Lennon             Freddie Mercury
Marvin Gaye             Bob Marley
Bob Dylan               Smokey Robinson
Otis Redding            Johnny Cash
Stevie Wonder           Etta James
James Brown             David Bowie
Paul McCartney          Van Morrison
Little Richard          Michael Jackson
Roy Orbison             Jackie Wilson

You can get this as a list of strings here.
Task
Given a singer name, print or return a letter from A to Z which uniquely identifies this singer. (If your code returns A for Bob Dylan, then it cannot return A for any other singer.)
As opposed to other similar challenges, the mapping is up to you as long as it's collision-free.
Rules

The input is guaranteed to be one of the 26 singer names listed above with this exact spelling and without any leading or trailing whitespace.
You may output the letter in either lowercase or uppercase. But it must be consistent.
You are encouraged to provide a test suite for all 26 possible inputs.
This is code-golf, so the shortest answer in bytes wins!

(Deleted sandbox entry.)

Dear Rolling Stone: Bob Dylan is truly one of the greatest musicians ever. But a great singer?

@LuisMendo I'm a bit salty about a few of these choices as well (cough cough where's Steve Tyler cough)

@LordFarquaad Steve Tyler is #99 ¯\(ツ)/¯

this may help somebody but I don't have the CG skills to use the info: the 1-6, 1-8, and 3-5 letters of the names are unique combinations.

MATL, 28 bytes
s98\40\2Y2'ijkl o qst uz'hw)

Try it online!
Explanation
s98\40\

Implicitly get the input string. Sum the characters of the input string, and do it modulus 98 followed by modulus 40. Results in one of the following numbers: 38 18 13 34 29 23 27 30  5 28 22  1  0 16  7 32  8 14  3 36 25  4  2  6 24 35  (in order of the Pastebin list).
2Y2'ijkl o qst uz'h

Push the (lowercase) alphabet with 2Y2. This takes care of the numbers in the range [1,26]. However, some numbers are missing, and we have numbers up to 38. Hence, we append (h) a string that takes care of the higher numbers, by mapping these numbers to the 'missing' letters. The spaces can be anything, I used capital letters in my original program for my own convenience.
w)

We can now index the number from the first step into the string from the second step with ). We use w to get the arguments in the correct order. While it may seem that we use 0-based indexing (the numbers vary from 0 to 38, and the string is 39 characters long), the reality is actually a bit more complicated: we use 1-based modular indexing, a feature unique to MATL. This means that 1 indexes to a, 38 actually indexes to u, and 0 indexes to the final z of the string.

Python 2, 80 71 bytes
def f(s):i=sum(map(ord,s))%98%40;return chr(i-i/26*18+i/32*3-i/37*8+65)

Try it online!
The sums of ordinals modded give numbers between 0 and 38
The numbers larger than 25 are then shifted to fill in the blanks as below (sorted sequence shown):
  0  1  2  3  4  5  6  7  8  -  -  -  - 13 14  - 16  - 18  -  -  - 22 23 24 25  - 27 28 29 30  - 32  - 34 35 36  - 38

Subtract 18 if i>25:
  0  1  2  3  4  5  6  7  8  -  -  -  - 13 14  - 16  - 18  -  -  - 22 23 24 25
                          - 27 28 29 30  - 32  - 34 35 36  - 38

Add 3 if i>31:
  0  1  2  3  4  5  6  7  8  -  -  -  - 13 14  - 16  - 18  -  -  - 22 23 24 25
                          - 27 28 29 30
                                                  - 32  - 34 35 36  - 38

Subtract 8 if i>37:
  0  1  2  3  4  5  6  7  8  -  -  -  - 13 14  - 16  - 18  -  -  - 22 23 24 25
                          - 27 28 29 30
                                                  - 32  - 34 35 36
                                            - 38

Which gives the sequence 0..25
  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

These are then converted to A-Z with chr(i+65)

I think you can shorten (i>31) to i/32, etc

6502 machine code routine (C64), 83 bytes
20 FD AE 20 9E AD 85 FC 20 A3 B6 A9 79 85 FB A0 00 84 FD B1 22 10 03 69 A0 18
45 FD 65 FB 85 FD E6 FB C8 C4 FC D0 EC E9 29 B0 FC 69 29 C9 1A 90 1C 29 0F C9
0D 90 04 69 09 90 12 C9 02 F0 0F C9 08 D0 04 A9 06 D0 06 C9 0C D0 02 A9 11 18
69 41 4C D2 FF

This is position-independent code, just put it somewhere in RAM and jump there, e.g. using the sys command.
Online demo (loads to $C000/49152).
Usage: sys49152,"[name]", e.g. sys49152,"Aretha Franklin".
Important: If the program was load from disk (like in the online demo), issue a new command first! This is necessary because loading a machine program trashes some C64 BASIC pointers.
Note: The C64 is by default in a mode without lowercase letters -- in order to be able to enter readable names, switch to lowercase mode first by pressing SHIFT+CBM.

Explanation
The challenge is in fact to find a minimal perfect hash function for these names; for the C64, I had to find one that's easily computable in simple 8bit operations. Here's a commented disassembly listing:
.C:c000  20 FD AE    JSR $AEFD          ; consume comma
.C:c003  20 9E AD    JSR $AD9E          ; evaluate expression
.C:c006  85 FC       STA $FC            ; save string length
.C:c008  20 A3 B6    JSR $B6A3          ; free string
.C:c00b  A9 79       LDA #$79           ; value for adding during hashing
.C:c00d  85 FB       STA $FB
.C:c00f  A0 00       LDY #$00           ; offset for reading string
.C:c011  84 FD       STY $FD            ; and initial hash value
.C:c013   .hashloop:
.C:c013  B1 22       LDA ($22),Y        ; read next character from string
.C:c015  10 03       BPL .xor           ; if bit 8 set (shifted)
.C:c017  69 A0       ADC #$A0           ; translate to same unshifted character
.C:c019  18          CLC
.C:c01a   .xor:
.C:c01a  45 FD       EOR $FD            ; xor with previous hash
.C:c01c  65 FB       ADC $FB            ; add offset
.C:c01e  85 FD       STA $FD            ; store new hash
.C:c020  E6 FB       INC $FB            ; increment offset
.C:c022  C8          INY
.C:c023  C4 FC       CPY $FC
.C:c025  D0 EC       BNE .hashloop      ; repeat until last character
.C:c027   .modloop:
.C:c027  E9 29       SBC #$29           ; subtract $29 until
.C:c029  B0 FC       BCS .modloop       ; underflow, then
.C:c02b  69 29       ADC #$29           ; add once again ( => mod $29)
.C:c02d  C9 1A       CMP #$1A           ; value in hash range?
.C:c02f  90 1C       BCC .tochar        ; -> output
.C:c031  29 0F       AND #$0F           ; mask lowest 4 bits only
.C:c033  C9 0D       CMP #$0D           ; greater 12 ?
.C:c035  90 04       BCC .fixedvals
.C:c037  69 09       ADC #$09           ; then just add 10 (9 plus carry)
.C:c039  90 12       BCC .tochar        ; and done -> output
.C:c03b   .fixedvals:
.C:c03b  C9 02       CMP #$02           ; 2 becomes 3 by adding
.C:c03d  F0 0F       BEQ .tochar2       ; with carry (jump after the CLC)
.C:c03f  C9 08       CMP #$08           ; if value was 8
.C:c041  D0 04       BNE .check2
.C:c043  A9 06       LDA #$06           ; new value is 6
.C:c045  D0 06       BNE .tochar        ; and output
.C:c046   .check2:
.C:c047  C9 0C       CMP #$0C           ; else if value was 12
.C:c049  D0 02       BNE .tochar
.C:c04b  A9 11       LDA #$11           ; new value is 17
.C:c04d   .tochar:
.C:c04d  18          CLC
.C:c04d   .tochar2:
.C:c04e  69 41       ADC #$41           ; add character code for 'a'
.C:c050  4C D2 FF    JMP $FFD2          ; jump to kernal CHROUT routine

Test suite (C64 BASIC, containing the machine code routine in data lines)
0fOa=49152to49234:rEb:pOa,b:nE:pO53272,23
1sY49152,"Aretha Franklin":?":Aretha Franklin"
2sY49152,"Ray Charles":?":Ray Charles"
3sY49152,"Elvis Presley":?":Elvis Presley"
4sY49152,"Sam Cooke":?":Sam Cooke"
5sY49152,"John Lennon":?":John Lennon"
6sY49152,"Marvin Gaye":?":Marvin Gaye"
7sY49152,"Bob Dylan":?":Bob Dylan"
8sY49152,"Otis Redding":?":Otis Redding"
9sY49152,"Stevie Wonder":?":Stevie Wonder"
10sY49152,"James Brown":?":James Brown"
11sY49152,"Paul McCartney":?":Paul McCartney"
12sY49152,"Little Richard":?":Little Richard"
13sY49152,"Roy Orbison":?":Roy Orbison"
14sY49152,"Al Green":?":Al Green"
15sY49152,"Robert Plant":?":Robert Plant"
16sY49152,"Mick Jagger":?":Mick Jagger"
17sY49152,"Tina Turner":?":Tina Turner"
18sY49152,"Freddie Mercury":?":Freddie Mercury"
19sY49152,"Bob Marley":?":Bob Marley"
20sY49152,"Smokey Robinson":?":Smokey Robinson"
21sY49152,"Johnny Cash":?":Johnny Cash"
22sY49152,"Etta James":?":Etta James"
23sY49152,"David Bowie":?":David Bowie"
24sY49152,"Van Morrison":?":Van Morrison"
25sY49152,"Michael Jackson":?":Michael Jackson"
26sY49152,"Jackie Wilson":?":Jackie Wilson"
27dA32,253,174,32,158,173,133,252,32,163,182,169,121,133,251,160,0,132,253,177
28dA34,16,3,105,160,24,69,253,101,251,133,253,230,251,200,196,252,208,236,233
29dA41,176,252,105,41,201,26,144,28,41,15,201,13,144,4,105,9,144,18,201,2,240
30dA15,201,8,208,4,169,6,208,6,201,12,208,2,169,17,24,105,65,76,210,255

Online demo of test suite.

Python 2, 68 bytes
def f(n):i=hash(n)%337%125%45;return chr(65+i-i/25*2-i/29*21+i/35*2)

Try it online!

interesting to know how did you compose this

@SargeBorsch hash(n) computes an unique integer for every names. The modulo operations still keep those ints unique, but lowers their value. The second part (chr(65+i-i/25*2-i/29*21+i/35*2)) is similar to TFelds answer. The modulo operations are bruteforced by a script which I already used here and here.

Javascript, 138 132 characters
As all initials are unique, except for MJ = Michael Jackson / Mick Jagger, I check for Michael Jackson specifically (the only one with an h on the 4th position), and for all other names I created a string with the initials followed by a unique letter.
s=>s[3]=='h'?'y':"AFaRCbEPcSCdJLeMGfBDgORhSWiJBjPMCkLRlROmAGnRPoMJpTTqFMrBMsSRtJCuEJvDBwVMxJWz".split(s.replace(/[^A-Z]/g,''))[1][0]

Code Snippet
Try it here:

var solution =
s=>s[3]=='h'?'y':"AFaRCbEPcSCdJLeMGfBDgORhSWiJBjPMCkLRlROmAGnRPoMJpTTqFMrBMsSRtJCuEJvDBwVMxJWz".split(s.replace(/[^A-Z]/g,''))[1][0]

var testnames = [
"Aretha Franklin",
"Ray Charles",
"Elvis Presley",
"Sam Cooke",
"John Lennon",
"Marvin Gaye",
"Bob Dylan",
"Otis Redding",
"Stevie Wonder",
"James Brown",
"Paul McCartney",
"Little Richard",
"Roy Orbison",
"Al Green",
"Robert Plant",
"Mick Jagger",
"Tina Turner",
"Freddie Mercury",
"Bob Marley",
"Smokey Robinson",
"Johnny Cash",
"Etta James",
"David Bowie",
"Van Morrison",
"Michael Jackson",
"Jackie Wilson"
];
testnames.forEach(name=>document.body.append( solution(name) ));

There may be a shorter hashing function, but I like the idea of trying something a human might do. However, I do wish you'd use the code snippet feature instead of linking to JSFiddle.

@trlkly I used the code snippet feature now.

Java (OpenJDK 8), 128 126 115 113 bytes
Not too shabby for a java submission!
Thanks to Kevin for saving me a whole lot of bytes with the lambda expressions!
s->{int a=0;for(int i:s.substring(1,6).getBytes())a+=i;a*=a==431?0.108:2.65108;return(char)(a==1341?70:a%26+65);}

Try it online!

Nice answer, +1 from me. I'm currently also working on a Java solution by creating a script.. No luck so far though. Btw, you can golf two bytes by changing {a+=i;} to a+=i;

@KevinCruijssen Cheers, can't believe I missed that! I wrote a script to try and find the 'magic number' that would give me unique values between 0 and 25 but the best I could do was 24, hence the if statements at the end.

Hmm btw, since you are using Java 8, you can also golf char g(String s) to s->. I've modified your TIO to show how to do this, in case you're only used to Java 7 methods.

Thanks, I never realised you could do that, I'll update my submission (again!)

Hahaha, you can tell I'm new to this

s->{char a=0;for(int i:s.substring(1,6).getBytes())a+=i;a*=a==431?.29:2.65108;a%=a==1341?8:26;return a+=65;} (108 bytes)

A port of TFeld's Python 2 answer is 74 bytes long.

Python 3, 132 99 96 bytes
lambda m:chr(98+"ԇ̲ЙГ̫ѼӿИԸՋжʾҍϴЬֺΝעЕΞϾҞ֜ӣ֪".find(chr(sum(map(ord,m)))))

Try it online!
Not golfed brilliantly, but I thought I'd give this a go.
-33 bytes thanks to modifications made by TFeld.
-3 bytes by using find instead of index thanks to ovs.

You can save 6 bytes by using sum(map(ord,m)), also I added Aretha Franklin for 128 bytes

And you can use chr(97+...) instead of ascii_lowercase : 99 bytes

What about an explanation?

An explanation: sum(map(ord,m)) adds up the ASCII values of the characters in the string m (gives integers in range 702–1506). Then calling chr it converts it to a (Unicode) character with that number: chr(702) is ʾ  to chr(1506) = ע and lots in between. This solution simply looks up this character in a list of all possible (26) such characters to get the index (0–26), then returns character with ASCII code 97 + that index (so 'a' to 'z').

96 bytes

Your current solution still contains a 99 byte version. You meant to use OVS's version ?

Perl, 56, 54, 50, 46 +1 (-p) bytes
$=crypt$,DT;/..(.)/;$_=$1;y/01268ADIJNVW/adhilmnpqsux/
$=crypt$,DT;/..(.)/;$=$1;y/01268JVW/hlmpqsux/;$=lc
$=crypt$,mO;/..(.)/;$=$1;y/035eft/AHPRXZ/;$=lc
Thanks to Dom's comment could save 4 more bytes, also changed to uppercase to fit better requierements.
$_=crypt$_,mO;y/035eft/AHPRXZ/;/..(.)/;$_=uc$1

Try It Online

Nice approach! I think you need to write/score a whole callable function though?

@FelixPalmen, it's a perl program which can be called inline : perl -pe '$_=crypt$_,mO;/..(.)/;$_=$1;y/035eft/AHPRXZ/;$_=lc' adding link to tio

Nice! Was looking for a similar approach, using $1^$2 but didn't think to use crypt... You can save 4 bytes with some re-ordering: Try it online!

PHP, 90 88 86 72+1 bytes
might become even shorter with a different modulo.
<?=strtr(chr(hexdec(substr(md5($argn),0,2))%65+58),"^<adins",bcfgqvx)&_;

Save to file and run as pipe with -nF or try it online.

Aretha Franklin and Paul McCartney both output W on your test cases, and there is no X output. Don't know if it's an error in the code itself or just the try it online conversion :)

@crazyloonybin replacement typo fixed. Thanks for hinting.

So how do I run this? Your 'try it online' code doesn't use the <?= part. And the 'Run as pipe` I'm not getting working. Also, I get notices when trying to run it from command line.

@Titus : In CodeGolf you should give the complete function or application that generates (only) the desired output. I'm familiar with <?= ... So my question still is, how do I run your code (from command line)? I fail at feeding it $argn in command line... All my tries so far either give artifacts, and still seem to require more code to get it to run.

@nl-x Your PHP yields notices, it´s because you didn´t give it the n option: echo <input> | php -nF <scriptfilename>

@nl-x the complete application is in the code block above. please stop pennypicking.

Python 2, 50 43 bytes
Credit to japh for the new version
lambda n:chr(hash(n)%2354%977%237%54%26+65)

Try it online!
Note: This is dependent on the hash builtin and will not work in all implementations

43 bytes: lambda n:chr(hash(n)%2354%977%237%54%26+65)

@japh Nice! My python brute force checker clearly wasn't fast enough ;)

Ruby, 63 bytes
->s{((0x3c4001c151861b27d>>s.sum%98%66).to_s(2).sum%48+64).chr}

Adds the ascii codes of the input, takes them mod 98 and then mod 66 to get a one of 26 unique numbers n in the range 0..65. The huge hexadecimal number contains a 1 bit in each of these 26 places, so by rightshifting it by n we obtain a number with 1..26 1 bits in it. We count the 1 bits by adding the ascii codes and taking mod 48, then add 64 and convert to an ASCII code.
Test program
the map iterates through the singers printing the letter code and singer. It then returns an array of the letter codes, which is sorted to demonstrate that each letter is used once.
f=->s{((0x3c4001c151861b27d>>s.sum%98%66).to_s(2).sum%48+64).chr}
a= [
  "Aretha Franklin","Ray Charles",
  "Elvis Presley","Sam Cooke",
  "John Lennon","Marvin Gaye",
  "Bob Dylan","Otis Redding",
  "Stevie Wonder","James Brown",
  "Paul McCartney","Little Richard",
  "Roy Orbison","Al Green",
  "Robert Plant","Mick Jagger",
  "Tina Turner","Freddie Mercury",
  "Bob Marley","Smokey Robinson",
  "Johnny Cash","Etta James",
  "David Bowie","Van Morrison",
  "Michael Jackson","Jackie Wilson"
]

p a.map{|i|p [f[i],i];f[i]}.sort

Output
["S", "Aretha Franklin"]
["E", "Ray Charles"]
["R", "Elvis Presley"]
["J", "Sam Cooke"]
["X", "John Lennon"]
["C", "Marvin Gaye"]
["M", "Bob Dylan"]
["W", "Otis Redding"]
["V", "Stevie Wonder"]
["Y", "James Brown"]
["D", "Paul McCartney"]
["Q", "Little Richard"]
["Z", "Roy Orbison"]
["P", "Al Green"]
["O", "Robert Plant"]
["K", "Mick Jagger"]
["N", "Tina Turner"]
["L", "Freddie Mercury"]
["G", "Bob Marley"]
["I", "Smokey Robinson"]
["A", "Johnny Cash"]
["F", "Etta James"]
["H", "David Bowie"]
["U", "Van Morrison"]
["B", "Michael Jackson"]
["T", "Jackie Wilson"]
["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

JavaScript (Chrome), 102
Note Unfortunately it works only in Chrome, because of implementation-dependent approximations in parseInt() (thanks @Arnauld)
s=>s[0]=='L'?'z':"ab.c..defghijklmn...o..pqrst.u.vwxy"[parseInt(s.replace(/ /,'o').slice(0,14),36)%35]

I looked for a hash function, taking a slice of each name, converting to numbers using base 36 and then applying a modulo.
I used this code to look for the best hash:
x=`Al Green\nAretha Franklin\nBob Dylan\nBob Marley\nDavid Bowie\nElvis Presley\nEtta James\nFreddie Mercury\nJackie Wilson\nJames Brown\nJohn Lennon\nJohnny Cash\nLittle Richard\nMarvin Gaye\nMichael Jackson\nMick Jagger\nOtis Redding\nPaul McCartney\nRay Charles\nRobert Plant\nRoy Orbison\nSam Cooke\nSmokey Robinson\nStevie Wonder\nTina Turner\nVan Morrison`.split(`\n`)

max=0
for(m=26;m<60;m++)
  for(i=0;i<20;i++)
    for(j=i;++j<20;)
      for(k=0;k<37;k++)
      {
        S=new Set();
        f=k ? (k-1).toString(36) : ''
        x.forEach(x=>(n=parseInt(x.replace(/ /,f).slice(i,j),36)%m, S.add(n)))
        if (S.size > max) console.log(i,j,f,m,max=S.size)
      }

And the results:
0 1 "" 26 14
0 2 "" 26 15
0 4 "" 26 16
0 5 "" 26 18
0 6 "0" 26 19
0 6 "3" 26 20
0 8 "a" 26 21
2 5 "7" 28 23
0 14 "h" 35 24
0 14 "o" 35 25
2 9 "" 51 26

The best hash function gives 26 different values between 0 and 50, but I used a different one, with 1 duplicate but a smaller range.
Test

var names=x=`Al Green\nAretha Franklin\nBob Dylan\nBob Marley\nDavid Bowie\nElvis Presley\nEtta James\nFreddie Mercury\nJackie Wilson\nJames Brown\nJohn Lennon\nJohnny Cash\nLittle Richard\nMarvin Gaye\nMichael Jackson\nMick Jagger\nOtis Redding\nPaul McCartney\nRay Charles\nRobert Plant\nRoy Orbison\nSam Cooke\nSmokey Robinson\nStevie Wonder\nTina Turner\nVan Morrison`.split(`\n`)

var F=
s=>s[0]=='L'?'z':"ab.c..defghijklmn...o..pqrst.u.vwxy"[parseInt(s.replace(/ /,'o').slice(0,14),36)%35]

var Singers={}
names.forEach(n=>Singers[F(n)]=n)

;Object.keys(Singers).sort().forEach(i=> console.log(i, Singers[i]))

You may want to mention that it only works on Chrome because of implementation-dependent approximations in parseInt().

@Arnauld thanks, I did not know.

Octave, 85 83 80 74 bytes
@(n)('A':'Z')(mod(n([1 2 8])*[1;15;47],124)=='#iZo,gp<C&4Y1!8-G`Kn3wtTIO')

This mess of an anonymous is the result of some messing around in MATLAB trying to find a good way to encode the data.
Basically after a quick analysis, only letters 1,2, and 8 of the input string (smallest string is 8 chars, so we are good) are needed to produce a unique value from each input. The hard part is then converting that unique value into something usable.
MATLAB is terrible at compressing data, so I had to look for another way to make the lookup mapping. I set out trying to find some function on the three input letters that resulted in a unique value that was also a printable ASCII value so that I could embed the mapping in a string of one character per input.
It turns out that matrix multiplying the characters at index [1 2 8] by the integer matrix [1;15;47] and then performing mod 124 results in unique values which all printable ASCII (and none are a ' character which would bugger up string literals). Pleasingly the mapping ends with TIO which is completely accidental. Interestingly this is the only mapping for this equation that gives 26 unique printable ASCII characters.
So basically that is my lookup mapping and calculation. Doing the lookup is simply a case of performing the calculation and comparing with the mapping. Adding on 'A'-1 to the index in the map results in a character A-Z.
You can try it online on TIO, which shows the full mapping of inputs and outputs. For completeness the full mapping is also below:
'Aretha Franklin' ==> B
'Ray Charles'     ==> S
'Elvis Presley'   ==> F
'Sam Cooke'       ==> V
'John Lennon'     ==> L
'Marvin Gaye'     ==> N
'Bob Dylan'       ==> C
'Otis Redding'    ==> Q
'Stevie Wonder'   ==> X
'James Brown'     ==> I
'Paul McCartney'  ==> R
'Little Richard'  ==> M
'Roy Orbison'     ==> T
'Al Green'        ==> A
'Robert Plant'    ==> U
'Mick Jagger'     ==> P
'Tina Turner'     ==> Y
'Freddie Mercury' ==> H
'Bob Marley'      ==> D
'Smokey Robinson' ==> W
'Johnny Cash'     ==> K
'Etta James'      ==> G
'David Bowie'     ==> E
'Van Morrison'    ==> Z
'Michael Jackson' ==> O
'Jackie Wilson'   ==> J

Saved 2 bytes tweaking mapping to remove +32.
Saved 3 bytes by making Octave-only using logical indexing of 'A':'Z' rather than find.
Saved 6 bytes by doing sum of multiplications using matrix multiplication.

Clever approach, maybe too clever? 53 bytes, based on my MATL answer

@Sanchises possibly, but it was the approach I came up with ¯_(ツ)_/¯. You're welcome to post your version as a separate answer.

I figured, and I agree that it's more interesting to have different approaches than just copy the shortest approach. I just wanted to compare the approaches, I think yours is more clever but I suppose the dataset just allowed for an easy mod-based approach (not sure if that's a coincidence or statistically likely)

C, 65 55 49 bytes
h(char*s){return*s<77?(*s^s[5]+40)%13+65:(s[5]&s[4]+s[1])%13+78;}
h(char*s){return*(long*)s%887%392%224%120%67%40%26+65;}
Same approach as KSab's answer. C doesn't provide a string hash function like Python. Or does it?
h(char*s){return*(long*)s%2004%857%361%94%26+65;}

Try it online!
h returns an int whose values are the ASCII codes for A .. Z.

APL (Dyalog), 48 bytes
⎕A[' $%&().279<?@CL'⍳⎕UCS 78|7⊥⎕UCS⍞]

Assumes ⎕IO←0 (array indexing set to start from 0 instead of 1).
Try it online!
Explained
It's a complete program; the outer part ⎕A[] is indexing somewhere into the uppercase alphabet to get the output character. Inside the brackets it reads right-to-left, and ⍞ is a prompt for a string input. ⎕UCS turns that into Unicode char values. 78|7⊥ decodes those values as if they were digits in base 7, then takes the answer modulo 78 (brute forced to find a base and modulo combination which give usable ASCII character values). ⎕UCS again to turn that single number into a character, and look it up ⍳ in the magic string '...' of 26 identifier characters. That position becomes the index into the ⎕A[] uppercase alphabet. (There are control chars in the string, the ASCII codes are 11 14 18 20 22 23 24 25 26 30 31 32 36 37 38 40 41 46 50 55 57 60 63 64 67 76).
The full mapping is:
      singers←'Aretha Franklin' 'Al Green' 'Ray Charles' 'Robert Plant' 'Elvis Presley' 'Mick Jagger' 'Sam Cooke' 'Tina Turner' 'John Lennon' 'Freddie Mercury' 'Marvin Gaye' 'Bob Marley' 'Bob Dylan' 'Smokey Robinson' 'Otis Redding' 'Johnny Cash' 'Stevie Wonder' 'Etta James' 'James Brown' 'David Bowie' 'Paul McCartney' 'Van Morrison' 'Little Richard' 'Michael Jackson' 'Roy Orbison' 'Jackie Wilson'

      f←{⎕A[' $%&().279<?@CL'⍳⎕UCS 78|7⊥⎕UCS⍵]}

      ¯1⌽' ',(↑singers),f¨singers
┌→────────────────┐
↓P Aretha Franklin│
│J Al Green       │
│M Ray Charles    │
│N Robert Plant   │
│U Elvis Presley  │
│Z Mick Jagger    │
│L Sam Cooke      │
│G Tina Turner    │
│F John Lennon    │
│B Freddie Mercury│
│Q Marvin Gaye    │
│H Bob Marley     │
│K Bob Dylan      │
│C Smokey Robinson│
│D Otis Redding   │
│T Johnny Cash    │
│Y Stevie Wonder  │
│I Etta James     │
│X James Brown    │
│O David Bowie    │
│E Paul McCartney │
│V Van Morrison   │
│A Little Richard │
│S Michael Jackson│
│R Roy Orbison    │
│W Jackie Wilson  │
└─────────────────┘

And the sorted letters of the mapping is exactly the uppercase alphabet (no dupes or missing):
      f¨singers
┌→─────────────────────────┐
│PJMNUZLGFBQHKCDTYIXOEVASRW│
└──────────────────────────┘

      (⊂∘⍋⌷⊢) f¨singers    ⍝ sorted
┌→─────────────────────────┐
│ABCDEFGHIJKLMNOPQRSTUVWXYZ│
└──────────────────────────┘

      ⎕A ≡ (⊂∘⍋⌷⊢) f¨singers    ⍝ matches the alphabet
1

As you have unprintables in the code (which are out of the SBCS), I think the score should be in UTF-8 (60 bytes). Also, you can safely remove the last char in the lookup table for ⍳, saving a byte.

Javascript, 98 bytes
s=l=>("heCysvCm hirDb iiesm ultOyr rb c ndeMbeonh tdvMnacic".indexOf(l[4]+l[2])/2+10).toString(36)

I found that the combination of the 2nd and the 4th character of the names is unique for each of them.
Therefore I create a string with the combinations of name[4] + name[2], not name[2] + name[4] or I would have a repetition of the char group eh of the first name Aretha Franklin eh and when Smokey Robinson and Johnny Cash oehn are concatenated.
I could just move Johnny Cash to another position of the string and get a different mapping, but concatenating the 4th and the 2nd character in this order avoids the collision and leaves the dataset order intact without adding more length to the solution. So I decided to go that way (it's just personal preference)
I search for the position of the concatenation of the 4nd and 2nd letter of the given parameter in the string and divide it by 2 so that I get a number between 0 and 25. Then I add 10 and convert it to string from base 36, where 10 corresponds to a and 35 to z

let singers = [
  "Aretha Franklin",
  "Ray Charles",
  "Elvis Presley",
  "Sam Cooke",
  "John Lennon",
  "Marvin Gaye",
  "Bob Dylan",
  "Otis Redding",
  "Stevie Wonder",
  "James Brown",
  "Paul McCartney",
  "Little Richard",
  "Roy Orbison",
  "Al Green",
  "Robert Plant",
  "Mick Jagger",
  "Tina Turner",
  "Freddie Mercury",
  "Bob Marley",
  "Smokey Robinson",
  "Johnny Cash",
  "Etta James",
  "David Bowie",
  "Van Morrison",
  "Michael Jackson",
  "Jackie Wilson"
]

s=l=>("heCysvCm hirDb iiesm ultOyr rb c ndeMbeonh tdvMnacic".indexOf(l[4]+l[2])/2+10).toString(36)

singers.forEach(singer => console.log(s(singer), singer))

very cleaver the combination you found!

aaah yes. off course. i have something quite similar, but instead of adding the char to return in the string, the position of the occurance could save 25 chars. Clever!

Wolfram Language (Mathematica), 101 126 bytes
Alphabet[][[#&@@#&@@Position[(t=ToCharacterCode)@"nZ-Be_;f%d^q 0w@x~KDaLJ&`k",Total@t@#~Mod~98+32]]]&

+32 seems leading to the shortest stirng hashtable in Mathematica InputForm.
Try it online!

///, 390 231 bytes
/gg/U/
/a///b///c///d///e///f///g///h///i///j///k///l///m///n///o///p///q///r///s///t///u///v///w///x///y///z//
/ F//
/A //
/ G//
/ M//
/M //
/J B/X/
/J //
/L //
/ R//
/R C/Y/
/S C/Z/
/B D/K/
/ B//
/ J//
/ T//
/S W/I/
/R O/N/
/JU/U/
/R //
/E P/H/
/PC/Q/

Try it online!
231 bytes after removing the newlines.
This is very long, but /// cannot handle different characters generically. In other words, /// does not support regex.

Excel, 96 bytes
After too much time wasted trying other approaches, have implemented @Eduardo Paez's approach:
=CHAR(FIND(MID(A1,5,1)&MID(A1,3,1),"her DbMbdvsv tdeicsm hnhltirac c i uCyrbOyCmeoie nMn")/2+65)