# Given a number, program must return the alphabet letter correspondent

## The program

Given a number, program must return the alphabet letter correspondent.

## Rules

• The challenge here is to make it as short as possible, everyone knows it is a very easy program to do.
• The number is not zero-based, it means 1 is A, 2 is B, 3 is C and so it goes...
• Any language will be accepted.
• I suspect the winning answer will be tiny. – DavidC Sep 14 '12 at 2:53
• I think my answer won – dspyz Sep 18 '12 at 1:01
• @BernaMariano What does "given a number" mean? – Toothbrush Feb 20 '14 at 11:34
• @toothbrush If Goku gives you a 3, use 3. – BernaMariano Feb 25 '14 at 18:43
• @BernaMariano Well, I'm not sure what you mean, but is my answer OK, then? – Toothbrush Feb 25 '14 at 18:44

main = putChar $('a':['a'..'z']) !! c  Where c is the number. • There is a lot of unnecessary white space: main=putChar$('a':['a'..'z'])!!c works as well. However you can not assume input to be present in a certain variable, but then again returning from a function is acceptable, so f c=('a':['a'..'z'])!!c or equivalently (('a':['a'..'z'])!!) works. – Laikoni Mar 20 '18 at 10:54

# Java 8, 15 bytes (as lambda function)

n->(char)(n+64)


Try it online.

# Java 8, 84 bytes (as full program)

interface M{static void main(String[]a){System.out.printf("%c",new Byte(a[0])+64);}}


Try it online.

• This works only for single digit. Double digit input will fail. ex: give 10 as input and output still comes as A. You care considering charAt(0), for double digits, you have to consider 2 characters. – BarathVutukuri Mar 20 '18 at 10:46
• @BarathVutukuri Thanks, fixed! – Kevin Cruijssen Mar 20 '18 at 10:49

(['@'..]!!)


Try it online! This anonymous function indexes into the string "@ABCDEFG ...".

# Fortran (GFortran), 30 bytes

READ*,I
PRINT*,ACHAR(I+64)
END


My entry in the good ol' Fortran.

Try it online!

# FORTH 16 BYTES

: n 64 + EMIT ;


OUTPUT:

8 N
8 N H ok
5 N
5 N E ok
12 N
12 N L ok
12 N
12 N L ok
15 N
15 N O ok
23 N
23 N W ok
15 N
15 N O ok
18 N
18 N R ok
12 N
12 N L ok
4 N
4 N D ok


# Tcl, 31 bytes

puts [format %c [incr argv 64]]


Try it online!

# Japt, 2 bytes

dI


# PHP 442

$alphabet = Array('A' => 1,'B' => 2,'C' => 3,'D' => 4,'E' => 5,'F' => 6,'G' => 7,'H' => 8, 'I' => 9,'J' => 10,'K' => 11,'L' => 12,'M' => 13,'N' => 14,'O' => 15,'P' => 16,'Q' => 17, 'R' => 18,'S' => 19,'T' => 20,'U' => 21,'V' => 22,'W' => 23,'X' => 24,'Y' => 25,'Z' => 26 ) function testInputForAlphabetCharacter($input){
for($index = 0;$index < count($alphabet);$i = $i + 1){ if($alphabet[$index] ==$input){
echo($index); } } }$input = $_GET['input']; testInputForAlphabetCharacter($input);

• @scleaver... o_0 – Ian Brindley Feb 20 '14 at 9:30
• I agree with @IanBrindley, this is serious overkill... There's no chance of shrinking this down? – WallyWest Feb 20 '14 at 10:56
• echo chr(64+\$input); – Ian Brindley Feb 20 '14 at 13:29
• this is as small as i could get it – scleaver Feb 21 '14 at 23:11