g | x | w | all
Bytes Lang Time Link
364Scratch250723T151158ZRhaixer
020Vyxal 3250723T164858Zpacman25
157Nim 2250326T102737ZjanAkali
311Tcl170212T003121Zsergiol
177Janet250511T093031ZAdam
121Julia 1.0250326T005849ZMarcMush
029Pip250325T222328ZDLosc
208SAKO250325T195133ZAcrimori
133Bespoke250315T015958ZJosiah W
022Vyxal231106T192655Zemanresu
003Python231105T192056ZThe Empt
036Uiua231105T081313Zchunes
014QBIC161026T091939Zsteenber
032Actually160823T071554ZLeaky Nu
143BrainFlak161021T151225ZErik the
088Factor + math.unicode210331T003532Zchunes
6256Deadfish / Deadfish~210330T225217Zemanresu
267Elixir200823T115544Zpxeger
030Pyth200821T023118ZScott
224Whispers v2200820T182515Zcaird co
300Java 8190413T214122ZBenjamin
nan170214T172616ZShaun Be
020MathGolf190329T115804ZKevin Cr
042Husk190329T095101ZUnrelate
022Japt180529T011508ZBubbler
059Excel VBA180420T195458ZTaylor R
044Processing170214T103522Zuser4180
146Lua 5.3170215T161940ZIDid
071SmileBASIC170211T164336Z12Me21
147Ruby170215T120438ZG B
037PHP170214T121010Zaross
02405AB1E160825T224149Zacrolith
1222Funciton151218T053155ZTimwi
205Racket161023T132819Zrnso
134Haskell160825T203803ZLaikoni
066Perl 5151217T212607ZDoorknob
133Haskell161024T142107ZAngs
014Mouse2002151218T005126Zcat
026Jelly160921T134644ZErik the
035DC151217T212252Zuser1921
318BASH160826T083025ZSefa
nan160825T210624Zbb94
013Hexagony160823T131353ZLeaky Nu
078C160822T153912ZLeaky Nu
042J160301T201530ZConor O&
194Ruby160313T013100ZPaul Che
068DUP160301T050434ZMama Fun
026Jolf160312T231107ZConor O&
050Cardinal160312T220658ZM L
060Staq160312T214226ZM L
5046beeswax160311T224618ZM L
123JavaScript151218T071528Zuser8165
147PowerShell151219T043743ZTessella
089Hoon160302T212503ZRenderSe
100R160307T151639Zslamball
143MS Excel formulas160303T214148Zdnep
031Jelly160303T065241ZASCII-on
234C#151218T024410ZTimwi
134Visual Basic for Applications160302T211022Zdnep
052Dyalog APL151218T211416Zlirtosia
295Haskell160303T060728ZHEGX64
081Perl 6160302T031229ZHotkeys
068Visual Basic for Applications160302T204932Zdnep
07380386 machine code160301T193401Zanatolyg
165R160301T172849ZArgenis
092Math++151217T203536ZSuperJed
086><>160301T150259ZAaron
042dc160301T150656ZToby Spe
3612๐”ผ๐•Š๐•„๐•š๐•Ÿ151228T232952ZMama Fun
146Python 2151220T215327ZJoachim
033Seriously151218T082131Zuser4594
123R151222T004740Zmchen
202C151220T224055ZKhaled.K
091PHP151218T163047Zorp
099Prolog151217T194636ZEmigna
130Javascript Browser Env151218T061838Zrgajrawa
033Pyth151218T065121Zlirtosia
098Marbelous151220T094443Zoveracto
040Pyth151218T055428Zp1xel
274Python 2151218T143730Zแƒ‘แƒ˜แƒ›แƒ
041k4151219T084720ZAaron Da
041TIBASIC151217T231710Zlirtosia
303Darkness151218T153444Zsweerpot
112D1ffe7e45e151217T201210ZASCIIThe
030Japt151217T210202ZETHprodu
036O151218T010130Zjado
159Javascript151218T145722ZQwertiy
101Mathematica151218T132755ZMartin E
070Brainfuck151218T061144Zp1xel
024CJam151217T194602ZDennis
030MATL151217T221805ZDavid
044dc151217T211834ZDigital

Scratch, 364 bytes

Boring straightforward solution. A few bytes can definitely be shaved by thinking more creatively.

()+(                                                     // 0, 4 bytes
()+<not<                                                 // 1, 8 bytes
<not<>>+<not<                                            // 2, 13 bytes
(<not<>>+<not<>>)+<not<                                  // 3, 23 bytes
(<not<>>+<not<>>)*(<not<>>+<not<                         // 4, 32 bytes
(join(()+<not<>>)(()+()))/(<not<>>+<not<                 // 5, 40 bytes
(<not<>>+<not<>>)*((<not<>>+<not<>>)+<not<               // 6, 42 bytes
(((join(()+<not<>>)(()+()))-<not<>>)-<not<>>)-<not<      // 7, 51 bytes
((join(()+<not<>>)(()+()))-<not<>>)-<not<                // 8, 41 bytes
((join(()+<not<>>)(()+()))-<not<                         // 9, 32 bytes
(join(()+<not<>>)(()+(                                   // 10, 22 bytes
(join((<not<>>+<not<>>)*(<not<>>+<not<>>))(<not<>>+<not< // 42, 56 bytes

enter image description here

Explanation:

  1. ()+() converts to number by default, so in its empty form returns 0
  2. <not<>> is true in Scratch, so adding it to a blank ()+() gives 1
  3. Adding two <not<>>s yields 2
  4. Adding another <not<>> makes 3
  5. Multiplying (3) by itself returns 4
  6. (join(()+<not<>>)(()+())) is the concatenation of 1 and 0, or 10. Divided by (3), it gives us 5.
  7. 6 is represented as 2*3
  8. 7 is 10-3, 8 is 10-2, 9 is 10-1
  9. See (6) part 1
  10. 42 is 4 joined to 2

Vyxal 3, 20 bytes


โ€บ
โจฅ
โ€บโจฅ
โ‘ฃt
โ‘ ยฝ
โ‘ฃh
โ‘ฆแโˆ‘
โ‘ฅt
โ‘ โ€น
โ‘ 
โ˜…O

Vyxal It Online!

0
โ€Žโข0+1
โ€Žโฃ0+2
โ€Žโค0+1+2
โ€Žโขโก64 tail (4)
โ€Žโขโข10/2=5
โ€Žโขโฃ64 head = 6
โ€Žโขโค256 remove tail (25) digit sum = 7
โ€Žโฃโก128 tail = 8
โ€Žโฃโข10-1 = 9
โ€Žโฃโฃ10
โ€ŽโฃโคOrd(*) = 42 (I got super lucky on that one)
๐Ÿ’Ž

Created with the help of Luminespire.

Nim 2, 157 bytes

Nim doesn't have implicitly imported math constants =T

len []              # 0, 6 bytes
ord on              # 1, 6 bytes  - `on` is alias for true
                    #               `ord` converts to integer
NimMajor            # 2, 8 bytes  - Nim Major Version (2)
NimMajor.succ       # 3, 13 bytes - successor is next value
cint.sizeof         # 4, 11 bytes - C's int (int32), 4 bytes
cint.sizeof.succ    # 5, 16 bytes
int.sizeof-NimMajor # 6, 19 bytes - Nim's int is 8 bytes on amd64
int.sizeof.pred     # 7, 15 bytes - predecessor is previous value
int.sizeof          # 8, 10 bytes
int.sizeof.succ     # 9, 15 bytes
int.sizeof+NimMajor # 10,19 bytes
import posix
ENOMSG              # 42,19 bytes - posix constant

Try it online in Wandbox!

Nim 1 and 2, 165 163 bytes

-2 bytes thanks to Adamรกtor

len []
ord on
on.ord.succ
len [on,on,on]
cint.sizeof
cint.sizeof.succ
int.sizeof.pred.pred
int.sizeof.pred
int.sizeof
int.sizeof.succ
int.sizeof.succ.succ
import posix
ENOMSG

Try it online!

Tcl, 311 bytes

$argc[incr i][expr [incr j]+$j][expr [incr k]+$k+$k][expr [incr l]+$l+$l+$l][expr [incr m]+$m+$m+$m+$m][expr [incr n]+$n+$n+$n+$n+$n][expr int(exp([incr o]+$o))][expr int(exp([incr p]+$p))+$p][expr ([incr q]+$q+$q)**[incr q]][expr int(exp([incr r]+$r))+$r+$r+$r][expr [set t int(exp([incr s]+$s))]**[incr s]-$t]

Try it online!

I had to merge all lines for TIO to get me the byte count without the line separations, here it is everything separated:

Tcl, 322 bytes

$argc
[incr i]
[expr [incr j]+$j]
[expr [incr k]+$k+$k]
[expr [incr l]+$l+$l+$l]
[expr [incr m]+$m+$m+$m+$m]
[expr [incr n]+$n+$n+$n+$n+$n]
[expr int(exp([incr o]+$o))]
[expr int(exp([incr p]+$p))+$p]
[expr ([incr q]+$q+$q)**[incr q]]
[expr int(exp([incr r]+$r))+$r+$r+$r]
[expr [set t int(exp([incr s]+$s))]**[incr s]-$t]

Try it online!

This is the version stripped of instructions to put it on display. To try it, on the first line just prepend puts and in the others wrap them by puts [ before and ] after.

Or else, try with the full version, on

Tcl, 382 bytes

puts $argc
puts [incr i]
puts [expr [incr j]+$j]
puts [expr [incr k]+$k+$k]
puts [expr [incr l]+$l+$l+$l]
puts [expr [incr m]+$m+$m+$m+$m]
puts [expr [incr n]+$n+$n+$n+$n+$n]
puts [expr int(exp([incr o]+$o))]
puts [expr int(exp([incr p]+$p))+$p]
puts [expr ([incr q]+$q+$q)**[incr q]]
puts [expr int(exp([incr r]+$r))+$r+$r+$r]
puts [expr [set t int(exp([incr s]+$s))]**[incr s]-$t]

Try it online!

Janet, 177 bytes

(+)
(*)
(inc(*))
(+(*)(*)(*))
(+(*)(*)(*)(*))
(length *redef*)
(length(type{}))
(length(type(=)))
(length(type +))
(length(type not))
(length *executable*)
(*;(map|(length(type($)))[+ =]))

Explanation

(+)

+ is the variadic add function. It returns 0 when given no arguments.

(*)

* is the variadic multiply function. It returns 1 when given no arguments.

(inc(*))

inc is a function that adds 1 to its argument.

(+(*)(*)(*))
(+(*)(*)(*)(*))

Add three or four 1s.

(length *redef*)

*redef* is a constant equal to the keyword :redef, which is 5 characters long.

(length(type{}))

The type of {} is :struct, which is 6 characters long.

(length(type(=)))

= is the variadic equality function which checks if all arguments are equal. Its return type is :boolean, which is 7 characters long.

(length(type +))

The type of + is :function, which is 8 characters long.

(length(type not))

The type of not is :cfunction (a function implemented in C), which is 9 characters long.

(length *executable*)

*executable* is a constant equal to the keyword :executable, which is 10 characters long.

(*;(map|(length(type(\$)))[+ =]))

(Ignore the backslash, StackExchangeโ€™s Markdown is broken.) Evaluates the functions + and = with no arguments, gets the types of the results (:number and :boolean respectively) and multiplies their lengths.

Julia 1.0, 121 bytes

pi-pi
true
-~+true
floor(pi)
ceil(pi)
floor(pi+โ„ฏ)
floor(pi+pi)
ceil(pi+pi)
floor(pi*โ„ฏ)
floor(pi*pi)
ceil(pi*pi)
ceil((e=โ„ฏ)e^e)

Try it online!

โ„ฏ is the euler constant (3 bytes)

Pip, 29 bytes

i
o
#t
#h
#m
HVt
t-#m
t-#h
E#h
Dt
t
As+t

Attempt Them All Online!

Explanation

i     ; Variable preset to 0
o     ; Variable preset to 1
#t    ; Length of variable preset to 10
#h    ; Length of variable preset to 100
#m    ; Length of variable preset to 1000
HVt   ; Half of 10
t-#m  ; 10 minus length of 1000
t-#h  ; 10 minus length of 100
E#h   ; 2 to the power of (length of 100)
Dt    ; 10 decremented
t     ; 10
As+t  ; ASCII code of variable preset to space character, plus 10

SAKO, 208 bytes

A=A-A

A=A-A
A=A*A

A=A-A
A=A*A+A*A

A=A-A
A=A*A+A*A+A*A

A=A-A
A=A*A+A*A
A=A*A

A=A-A
A=A*A+A*A
A=A*A+A/A

A=A-A
A=A*A+A*A
A=A*A+A

A=A-A
A=A*A+A*A
A=A*A+A+A/A

A=A-A
A=A*A+A*A
A=A*(A+A/A)

A=A-A
A=A*A+A*A
A=(A+A/A)*A

A=A-A
A=A*A+A*A
A=(A+A/A)*A+A/A

A=A-A
A=A*A+A*A
A=(A*A+A)*A+(A*A+A)

Newlines between snippets added for readability.
All I really do here is turn A by subtraction into 0, then by 0*0 into 1 and do some one-based arithmetic.

Uses KW6 as its codepage so 207,75 bytes rounded up is 208 bytes.

Bespoke, 133 bytes

from A-B-C
said I
here is
only way
this code
will reach
each number
with letters
from alphabet
that everybody
can do a commentary
and/or poem in

Each line pushes the corresponding number (0, 1, 2, 3, etc.) onto the stack.

Running these snippets directly in the official interpreter with the -d flag will show these numbers after they're pushed onto the stack.

Stack: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 42]
Heap: {
    1: 0,
}

Vyxal, 22 bytes


โ€บ
โ‡ง
โ€บโ‡ง
โ‡งโ‡ง
โ‚€ยฝ
โ‡งT
โ‚€โ‡ฉโ€น
โ‚€โ‡ฉ
โ‚€โ€น
โ‚€
โ‚„Eโˆ‘โ‡ง

Try it Online!

I think all of these are optimal aside from maybe 7 and 42, but I couldn't find anything shorter. 0, 1, 2, and 10 are definitely optimal at least.

      # 0
โ€บ     # 0 + 1
โ‡ง     # 0 + 2
โ€บโ‡ง    # 0 + 1 + 2
โ‡งโ‡ง    # 0 + 2 + 2
โ‚€ยฝ    # 10  / 2
โ‡งT    # (0 + 2) * 3
โ‚€โ‡ฉโ€น   # 10 - 2 - 1
โ‚€โ‡ฉ    # 10 - 2
โ‚€โ€น    # 10 - 1
โ‚€     # 10
โ‚„Eโˆ‘โ‡ง  # digitsum(2 ** 26) + 2

Python 3

len([])
len([len])
len([len,len])
len([len,len,len])
len([len,len,len,len])
len([len,len,len,len,len])
len([len,len,len,len,len,len])
len([len,len,len,len,len,len,len])
len([len,len,len,len,len,len,len,len])
len([len,len,len,len,len,len,len,len,len])
len([len,len,len,len,len,len,len,len,len,len])
len([len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len,len])

Just lists and functions. No forbidden literals!

Definitely can be golfed, but I automatically generated these, so I might golf it later.

Uiua, 37 36 bytes

โŒŠโš‚
โŒŠฮท
โŒˆฮท
โŒŠฯ€
โŒˆฯ€
โŒˆ+ฯ€ฮท
โŒŠฯ„
โŒˆฯ„
โŒˆ+ฯ„ฮท
โŒŠร—ฯ€ฯ€
โŒˆร—ฯ€ฯ€
โŒŠ+ฯ„โฟฯ€ฯ€

Try it!

I will be curious to see if anyone has any two-byters for 0. I found a dozen three-byters. Found one!

โŒŠโš‚      # floor of random float in [0,1)
โŒŠฮท      # floor of eta (number of radians in a quarter circle)
โŒˆฮท      # ceiling of eta
โŒŠฯ€      # floor of pi (ratio of circle's circumference to diameter)
โŒˆฯ€      # ceiling of pi
โŒˆ+ฯ€ฮท    # ceiling of eta plus pi
โŒŠฯ„      # floor of tau (ratio of circle's circumference to radius)
โŒˆฯ„      # ceiling of tau
โŒˆ+ฯ„ฮท    # ceiling of eta plus tau
โŒŠร—ฯ€ฯ€    # floor of pi squared
โŒˆร—ฯ€ฯ€    # ceiling of pi squared
โŒŠ+ฯ„โฟฯ€ฯ€  # floor of pi to the pi plus tau

QBIC, 14 bytes

Thank you @Adรกm, for clarifying part of the rules. Brought the byecount down to 14.

a
q
r
s
t
u
v
w
x
y
z
v*w

All lower-case letters are numerical variables in QBIC, which default to 0. Exceptions are the letters q-z, which get initialised to 1-10. 42 is simply 6*7.

Actually, 32 bytes

โ•œ
โ•’K
 โŒ
โ•ฆL
โ•ฆK
โ•ฆLโŒ
โ•ฆLฯ„
โ• ยฒL
โ•ฆLโ•™
โ•ฆLยฒ
kYโ•ค
โ•’ยบโ•ฆ+L

All full programs. Try it online!

Explanation

For the last one:

โ•’ยบโ•ฆ+L
โ•’      ln(2)
 ยบ     convert from radian to degree (39.71440802747729)
  โ•ฆ+   + pi (42.85600068106709)
    L  floor

Brain-Flak, 172 143 bytes

(<>)
(())
(()())
(()()())
(()()()())
(()()()()())
((()()()){})
((()()()){}())
((()()()()){})
(((()()())){}{})
((()()()()()){})
(((((()()()){}()){})){}{})

Try it online! (copy-paste yourself)

Factor + math.unicode, 88 bytes

f ?1+
e e /
e โŒŠ
e โŒˆ
ฯ€ โŒˆ
ฯ† e^ โŒŠ
ฯ† e^ โŒˆ
e sq โŒŠ
e sq โŒˆ
ฯ€ sq โŒŠ
ฯ€ sq โŒˆ
ฯ† 10^ โŒˆ

Try it online!

Explanation:

f ?1+     ! ?1+: increment the input by 1 or return 0 if input is f
e e /     ! e (2.7182818...) divided by e
e โŒŠ       ! the floor of e
e โŒˆ       ! the ceiling of e
ฯ€ โŒˆ       ! the ceiling of pi (3.14159...)
ฯ† e^ โŒŠ    ! the floor of e raised to the phi (1.618033...) power
ฯ† e^ โŒˆ    ! the ceiling of e raised to the phi power
e sq โŒŠ    ! the floor of e squared
e sq โŒˆ    ! the ceiling of e squared
ฯ€ sq โŒŠ    ! the floor of pi squared
ฯ€ sq โŒˆ    ! the ceiling of pi squared
ฯ† 10^ โŒˆ   ! the ceiling of 10 raised to the phi power (10^ is a function)

Deadfish / Deadfish~, Score: 62 / 56

0: o

1: io

2: iio

3: iiio

4: iiso

5: iisio

6: iisiio

7: iiisddo or {i}dddo (Deadfish~ only)

8: iiisdo or {i}ddo (Deadfish~ only)

9: iiiso or {i}do (Deadfish~ only)

10: iiisio (Deadfish) or {i}o (Deadfish~)

42: iisiisiiiiiio (Deadfish) or {iiii}iio (Deadfish~)

Amazingly, up to 9, vanilla deadfish is as efficient! I put these together because they're almost identical.

Elixir, 267 bytes

Elixir's syntax doesn't exactly lend itself to golfing, and its strong typing makes this pretty hard too.

length []                                             # 0
length [[]]                                           # 1
length [[],[]]                                        # 2
floor :math.pi                                        # 3  (:math is technically a literal, but Elixir's atoms are neccessary to access many modules)
ceil :math.pi                                         # 4
length [[],[],[],[],[]]                               # 5
floor :math.pi+:math.pi                               # 6
ceil :math.pi+:math.pi                                # 7
(ceil :math.pi+:math.pi)+length [[]]                  # 8
floor :math.pi*:math.pi                               # 9
length(Atom.to_charlist URI)                          # 10 (URI is an alias to Elixir.URI which is 9 characters long)
(length(Atom.to_charlist Version))*(floor :math.pi)   # 42 (length of "Elixir.Version" times 3)

Try it online!

Pyth, 30 bytes

Z
hZ
hhZ
l`d
eCN
ePT
elG
sPT
ttT
tT
T
.ON

Try it online!

Breakdown: Z = Zero, T = Ten, G = alphabet.

Z    // 0: Zero
hZ   // 1: Zero + 1
hhZ  // 2: Zero + 1 + 1
l`d  // 3: length of the representation of ' '
eCN  // 4: The last digit of the ascii code for " (34)
ePT  // 5: Last digit of the prime factorials for 10 [2, 5]
elG  // 6: Last difit of the length of the alphabet
sPT  // 7: Sum of the prime factorials for 10
ttT  // 8: 10 - 1 - 1
tT   // 9: 10 - 1
T    // 10: 10
.ON  // 42: Octal value for the " character

Whispers v2, 224 bytes

> e
>> 1-1

> e
>> 1รท1

> e
>> โŒŠ1โŒ‹

> e
>> โŒˆ1โŒ‰

> ฯ€
>> โŒˆ1โŒ‰

> ฯ€
>> โŒˆ1โŒ‰
>> โ‰ป2

> ฯ€
>> 1+1
>> โŒŠ2โŒ‹

> e
>> 1ยฒ
>> โŒŠ2โŒ‹

> e
>> 1ยฒ
>> โŒˆ2โŒ‰

> ฯ€
>> 1ยฒ
>> โŒŠ2โŒ‹

> ฯ€
>> 1ยฒ
>> โŒˆ2โŒ‰

> e
>> โ‰ป1
>> 1*2
>> โŒˆ3โŒ‰

Each snippet is separated by two newlines. In Whispers, digits (0123456789) only refer to their numerical value when on a nilad line i.e. if the line begins with > . These lines simply return the value represented on the line. Used in the snippets are > e and > ฯ€ which return \$e\$ and \$\pi\$.

How they work

0 - 10 bytes

> e
>> 1-1

Try it online!

Return \$e - e = 0\$

1 - 11 bytes

> e
>> 1รท1

Try it online!

Returns \$e \div e = 1\$

2 - 14 bytes

> e
>> โŒŠ1โŒ‹

Try it online!

Returns \$\lfloor e\rfloor = 2\$

3 - 14 bytes

> e
>> โŒˆ1โŒ‰

Try it online!

Returns \$\lceil e\rceil = 3\$

4 - 15 bytes

> ฯ€
>> โŒˆ1โŒ‰

Try it online!

Returns \$\lceil\pi\rceil = 4\$

5 - 23 bytes

> ฯ€
>> โŒˆ1โŒ‰
>> โ‰ป2

Try it online!

Returns \$\lceil\pi\rceil+1=5\$

6 - 22 bytes

> ฯ€
>> 1+1
>> โŒŠ2โŒ‹

Try it online!

Returns \$\lfloor2\pi\rfloor=6\$

7 - 21 bytes

> e
>> 1ยฒ
>> โŒŠ2โŒ‹

Try it online!

Returns \$\lfloor e^2\rfloor = 7\$

8 - 21 bytes

> e
>> 1ยฒ
>> โŒˆ2โŒ‰

Try it online!

Returns \$\lceil e^2\rceil = 8\$

9 - 22 bytes

> ฯ€
>> 1ยฒ
>> โŒŠ2โŒ‹

Try it online!

Returns \$\lfloor\pi^2\rfloor = 9\$

10 - 22 bytes

> ฯ€
>> 1ยฒ
>> โŒˆ2โŒ‰

Try it online!

Returns \$\lceil\pi^2\rceil = 10\$

42 - 29 bytes

> e
>> โ‰ป1
>> 1*2
>> โŒˆ3โŒ‰

Try it online!

Returns \$\lceil e^{e+1}\rceil = 42\$

Java 8, 300 bytes

My only goal was to get every value using only java.lang.Math and integer casting. Because of that, it's probably not the best answer in terms of golf. I have fun making it, however, and that's what counts :)

If I had more time, I would have gone further and only used the constants Math.PI and Math.E.

(int)(Math.E-Math.E)              // 0
(int)(Math.E/Math.E)              // 1
(int)Math.E                       // 2
(int)Math.PI                      // 3
(int)(Math.E/Math.E+Math.PI)      // 4
(int)(Math.E+Math.E)              // 5
(int)(Math.PI+Math.PI)            // 6
(int)(Math.E+Math.E+(int)Math.E)  // 7
(int)(Math.E+Math.E+Math.E)       // 8
(int)(Math.PI*Math.PI)            // 9
(int)Math.ceil(Math.PI*Math.PI)   // 10
(int)Math.ceil(Math.pow(Math.PI,Math.PI)+Math.E+Math.E) //42

TIO code to evaluate all of these at once

Sinclair ZX81/Timex TX1000/1500 BASIC

After some discussion with Adรกm below, you have the following on the ZX81** (0 to 10 inclusive and 42), where explanations may be necessary, see the relevant note in the square brackets:

[1] .
[2] NOT .
(PI+PI)/PI
INT PI
INT PI+NOT .
INT (PI+PI)-NOT .
INT (PI+PI)
INT (PI+PI)+NOT .
INT (PI*PI+COS PI)
LEN STR$ PI
INT (PI*PI)+NOT .
[3] INT (PI**PI+PI+PI)

Notes:

  1. This is a short-hand of 0.0
  2. Not zero is 1, this is two keystrokes (so two bytes), which is shorter then PI/PI (three keystrokes)
  3. ** is to the power of, so it's the integer value of PI to the value of PI plus PI+PI

To see this in action, you can type it in as follows using Direct or Online mode in ZX BASIC:

PRINT .,NOT .,(PI+PI)/PI,INT PI,INT PI+NOT .,INT (PI+PI)-NOT .,INT (PI+PI),INT (PI+PI)+NOT .,INT (PI*PI+ COS PI),LEN STR$ PI,INT (PI*PI)+NOT .,INT (PI**PI+PI+PI)

Here is a more evil listing that I came up with that prints 1 to 10 inclusive (try typing it into a ZX81 emulator - actually don't):

1 PRINT LEN STR$ USR VAL (STR$ INT (EXP PI+PI)+STR$ (PI-PI)+STR$ (PI/PI+(PI/PI)))
2 PRINT (PI+PI)/PI
3 PRINT INT PI
4 PRINT INT (SGN PI+PI)
5 PRINT INT PI+(PI/PI)
6 PRINT INT (PI+PI)
7 PRINT INT ((PI+PI)+((PI/PI)))
8 PRINT INT (PI+PI+PI-SGN (PI))
9 PRINT LEN STR$ PI
10 PRINT INT (PI*PI)+PI/PI

MathGolf, 20 bytes

p   # 0
รฎ   # 1
โŒ    # 2
dยฑ  # 3
โ˜ปโˆš  # 4
โ™‚ยฝ  # 5
Bยฝ  # 6
Dยฝ  # 7
โ˜ปยฝ  # 8
dยฒ  # 9
โ™‚   # 10
Jโˆž  # 42

Try it online.

Explanation:

p   # Print the top of the stack (or 0 if there is no input, nor anything on the stack)
รฎ   # 1-indexed loop index (1 by default)
โŒ    # + 2 (which becomes 0+2 by default)
dยฑ  # Push -3, and then pop and push its absolute value
โ˜ปโˆš  # Push 16, square-rooted
โ™‚ยฝ  # Push 10, halved
Bยฝ  # Push 12, halved
Dยฝ  # Push 14, halved
Fยฝ  # Push 16, halved
dยฒ  # Push -3, squared
โ™‚   # Push 10
Jโˆž  # Push 21, doubled

Of course there any many alternatives for some.. i.e. 6 can alternatively be Xโˆš; ฯ„i; โ•Ÿx; Mยผ; Cยฝ; Nยผ; Oยผ; Pยผ; etc. (Try it online).

Husk, 42 bytes

With string and character literals forbidden as well as numbers, all Husk has to work with are sequence builtins: N (all natural numbers), รธ (empty list), and the ฤฐ family. (And functions which never get evaluated, on account of being wrapped, but that's a bit far from useful.)

Lรธ        Length of the empty list.
ยฌรธ        Negation of the empty list.
โ†ฤฐp       First prime. I wanted to use \. here, but even though there are no digits . is a (deliberate) corner case of numeric literal syntax and not a special constant.
โ†ฤฐฯ€       First digit of pi.
โ–กโ†tN      Second natural number, squared.
โ†ฤฐ5       First power of 5. (Power sequences only exist for 2, 3, 5, and 7; the digits are arbitrary labels.)
Dโ†ฤฐ3      First power of 3, times 2.
โ†ฤฐ7       First power of 7.
ยฝLฮ˜ฤฐโ‚ฌ     Length of the list of Euro denominations with a zero tacked on to the beginning, over 2.
โ–กโ†ฤฐฯ€      First digit of pi, squared.
โ†ฤฐโฐ       First power of 10.
Dโ†’Dโ†ฤฐโฐ    First power of 10, times 2, plus 1, times 2.

Japt, 22 bytes

0:  T       T == 0
1:  v       Implicit input 0; Number.v gives 1 if it's even, 0 otherwise
2:  y       Number.y(other) gives GCD of two numbers; `other` defaults to 2
3:  D-A     A == 10, D == 13; 13-10
4:  Gq      G == 16; 16.sqrt()
5:  Az      Number.z(other) gives this/other rounded towards 0; `other` defaults to 2
6:  Cz      C == 12
7:  Ez      E == 14
8:  Iq      I == 64
9:  Aร‰      ร‰ is a shortcut for `-1`
10: A       Obviously.
42: H+A     H == 32; 32+10

Try it online: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 42

Excel VBA, 59 bytes

Enums from the Excel object available to VBA. n is said to be an uninitialized variable and thus holds the default value of 0 as a Variant.

These snippets may be called to the VBE immediate window by prepending with ?. e.g. ?xlOr.

Further information on each response is commented to the right

00: -n          ''  2 bytes;  Uninitialized var `n` defaults to `0`
01: n^n         ''  3 bytes;  0^0=1
02: xlOr        ''  4 bytes;  Excel.XlAutoFilterOperator.xlOr
03: xlSet       ''  5 bytes;  Excel.XlCubeFieldType.xlSet
04: xlWKS       ''  5 bytes;  Excel.XlFileFormat.xlWKS
05: xlDXF       ''  5 bytes;  Excel.XlPictureConvertorType.xlDXF
06: xlCSV       ''  5 bytes;  Excel.XlFileFormat.xlCSV
07: xlCGM       ''  5 bytes;  Excel.XlPictureConvertorType.xlCGM
08: xlEPS       ''  5 bytes;  Excel.XlPictureConvertorType.xlEPS
09: xlTIF       ''  5 bytes;  Excel.XlPictureConvertorType.xlTIF
10: xlPCX       ''  5 bytes;  Excel.XlPictureConvertorType.xlPCX
42: xlWJ3+xlOr  ''  10 bytes; Excel.XlFileFormat.xlWJ3+Excel.XlAutoFilterOperator.xlOr

Processing, 65 44 bytes

X
Y
Z
HSB
Z*Z
LINES
HSB*Z
TAB-Z
MITER
X+TAB
-~TAB
BOX+Y

Explanation

Using the hint from the question, I decided to use Processing constants to produce these numbers. These constants contain a numerical value. So to gather them, I used PConstants.java.

Here is the list of all the constants I used:

X      == 0
Y      == 1
Z      == 2
HSB    == 3
LINES  == 5
MITER  == 8
TAB    == 9 (char)
BOX    == 41

After this, all that was left for me to do is to choose the combinations of these constants that produce the numbers 1 to 10 and 42. Finally, I ended up with these:

println(X);//0
println(Y);//1
println(Z);//2
println(HSB);//3
println(Z*Z);//2 * 2 = 4
println(LINES);//5
println(HSB*Z);//3 * 2 = 6
println(TAB-Z);//9 - 2 = 7
println(MITER);//8
println(X+TAB);//0 + 9 = 9
println(-~TAB);//-~9 = 10
println(BOX+Y);//41 + 1 = 42

Several notes:

TAB has a char value of 9, meaning that if I print TAB, I print a literal tab. So to convert it to an int, I just add 0 to it.

And that's it!

Edit

I discovered PConstants.java. It appears to contain all of the constants that exist in Processing. All that research I did is on the Processing Reference is not needed anymore. Time to cut down on the bytes :)

Lua 5.3, 146 bytes

Uses a lot of length operators. Version probably doesn't matter but it is dependent on the value of _VERSION so I might as well include it for clarity.

0. #{}
1. #{_G}
2. #{_G}+#{_G}
3. #type(x)
4. #type{}-#{_G}
5. #type{}
6. #type{}+#{_G}
7. #_VERSION
8. #type(load)
9. #type(load)+#{_G}
10. #_VERSION+#type(x)
42. - -(#type{}-#{_G}..#{_G}+#{_G})

Annotated with explainations:

0. #{}                 -- {} is an empty table, # is the length operator, length of empty table is 0.
1. #{_G}               -- {_G} is a table containing the global environment (itself a table), so there is one item.
2. #{_G}+#{_G}         -- 1+1
3. #type(x)            -- x is not set and so defaults to nil, type(nil) returns the string "nil", length of "nil" is 3.
4. #type{}-#{_G}       -- 5-1
5. #type{}             -- type of table is "table", length of "table" is 5, brackets not required when only argument is a table literal.
6. #type{}+#{_G}       -- 5+1
7. #_VERSION           -- _VERSION contains the current version as a string ("Lua 5.3"), of length 7.
8. #type(load)         -- type of 'load' is "function", length of "function" is 8.
9. #type(load)+#{_G}   -- 8+1
10. #_VERSION+#type(x) -- 7+3
42. - -(#type{}-#{_G}..#{_G}+#{_G}) -- concatenation operator implicitly converts numerical operands to strings, resulting in "4".."2"=="42". Double negation converts it to a number.

SmileBASIC, 73 71 bytes

#NO 'unknown use (maybe dialog box results?)
#UP 'd-pad up
#CHKZ 'used in SPCHK and BGCHK to get the z coordinate
#TRED 'text color red
#LEFT 'd-pad left
#BQLSF 'biquad low shelf filter
#BQHSF 'biquad high shelf filter
#BQPEQ 'biquad peaking equalizer
#CHKI 'used in SPCHK to check definition number
#TBLUE 'text color blue
#TPURPLE 'text color purple
#BQHSF*#BQPEQ '42

Ruby, 149 147 bytes

$.
-~$.
-~-~$.
-~-~-~$.
-~-~-~-~$.
-~-~-~-~-~$.
-~-~-~$.>>~$.
-~-~-~-~-~-~-~$.
-~$.>>~-~-~$.
-~$.>>~-~-~$.|-~$.
-~-~-~-~-~$.>>~$.
-~-~-~-~-~$.>>~-~-~$.|-~-~$.

Explanation:

$.is the number of the last line read from the current input file. Since we are not reading any file, this is initialized with 0.

1 through 5 are just the previous number +1, then I can use shifts for multiplication (negative right shift saves 1 byte) and or for addition (can't use +/- because of priority).

So, for example, 42 is 5>>-3|2

PHP, 38 37 bytes

Note: uses IBM-850 encoding.

+_          #0
+~โ•ฌ         #1
+~โ•         #2
+~โ•          #3
+~โ•ฆ         #4
+~โ•ฉ         #5
+~โ•”         #6
+~โ•š         #7
+~รƒ         #8
+~รฃ         #9
+~โ•ฌยค        #10
+~โ•ฆโ•        #42

Explanation

Undefined constants in PHP have their name as default value. The resulting string is then negated to result in "0", "42" etc. Finally, it's converted to integer using the leading +.

Tweaks

05AB1E, 40 38 24 bytes

ยพ
X
Y
XรŒ
Yยท
T;
T;>
T;รŒ
Tร
T<
T
ลพwT+

Funciton, 1222 bytes

Apart from numeric literals, there are two ways I can produce a value (any value at all) in Funciton: stdin and lambda expressions. Stdin is a single box while a full lambda expression requires more syntax, so Iโ€™m going with stdin. However, while stdin could be anything, all of the following work regardless of what input is provided.

All of the library functions used here existed before the challenge was posted.

0 (40 bytes in UTF-16)

โ•”โ•—โ”Œโ”
โ•‘โ•Ÿโ”คโ””โ”ผโ”ฌโ”
โ•šโ•โ””โ”€โ”˜โ””โ”˜

This uses the raw syntax for less-than. A value is never less than itself, so the result of this is 0.

1 (52 bytes in UTF-16)

โ•”โ•—โ”Œโ”€โ•–โ”Œโ”€โ•–
โ•‘โ•Ÿโ”คโŒ‘โ•Ÿโ”คษ•โ•Ÿ
โ•šโ•โ•˜โ•โ•โ•˜โ•โ•

โŒ‘ returns a lazy sequence containing a single element and ษ• counts the number of elements. (The lazy sequence is lazy enough that this snippet doesnโ€™t actually evaluate stdin at all!)

2 (70 bytes in UTF-16)

โ•”โ•—โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–
โ•‘โ•Ÿโ”คโŒ‘โ•Ÿโ”คส‚โ•Ÿโ”คษ•โ•Ÿ
โ•šโ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•

= 2ยน. ส‚ generates all subsequences of a sequence, and thus turns a sequence of n elements into one with 2โฟ.

3 (88 bytes in UTF-16)

โ•”โ•—โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–
โ•‘โ•Ÿโ”คโŒ‘โ•Ÿโ”คส‚โ•Ÿโ”คษ•โ•Ÿโ”คโ™ฏโ•Ÿ
โ•šโ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•

= 2 + 1. โ™ฏ increments a value by 1.

4 (88 bytes in UTF-16)

โ•”โ•—โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–
โ•‘โ•Ÿโ”คโŒ‘โ•Ÿโ”คส‚โ•Ÿโ”คส‚โ•Ÿโ”คษ•โ•Ÿ
โ•šโ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•

= 2ยฒ.

5 (106 bytes in UTF-16)

โ•”โ•—โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–
โ•‘โ•Ÿโ”คโŒ‘โ•Ÿโ”คส‚โ•Ÿโ”คส‚โ•Ÿโ”คษ•โ•Ÿโ”คโ™ฏโ•Ÿ
โ•šโ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•

= 4 + 1.

6 (106 bytes in UTF-16)

โ•”โ•—โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–
โ•‘โ•Ÿโ”คโŒ‘โ•Ÿโ”คส‚โ•Ÿโ”คษ•โ•Ÿโ”คโ™ฏโ•Ÿโ”ค!โ•Ÿ
โ•šโ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•

= 3 factorial.

7 (110 bytes in UTF-16)

โ”Œโ”€โ”€โ”€โ”โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ•”โ•—
โ”‚โ”Œโ”€โ•–โ”œโ”คษ•โ•Ÿโ”คส‚โ•Ÿโ”คโŒ‘โ•Ÿโ•ขโ•‘
โ””โ”คAโ•Ÿโ”˜โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•šโ•
 โ•˜โ•คโ•

= A(2, 2) (Ackermann function).

8 (118 bytes in UTF-16)

โ”Œโ”€โ”€โ”€โ”€โ”โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ•”โ•—
โ”‚โ”Œโ”€โ”€โ•–โ”œโ”คษ•โ•Ÿโ”คส‚โ•Ÿโ”คโŒ‘โ•Ÿโ•ขโ•‘
โ””โ”ค<<โ•Ÿโ”˜โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•šโ•
 โ•˜โ•คโ•โ•

= 2 << 2 (shift-left).

9 (128 bytes in UTF-16)

โ”Œโ”€โ”€โ”€โ”โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ•”โ•—
โ”‚โ”Œโ”€โ•–โ”œโ”คโ™ฏโ•Ÿโ”คษ•โ•Ÿโ”คส‚โ•Ÿโ”คโŒ‘โ•Ÿโ•ขโ•‘
โ””โ”คร—โ•Ÿโ”˜โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•šโ•
 โ•˜โ•คโ•

= 3 ร— 3.

10 (146 bytes in UTF-16)

โ”Œโ”€โ”€โ”€โ”โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ•”โ•—
โ”‚โ”Œโ”€โ•–โ”œโ”คโ™ฏโ•Ÿโ”คษ•โ•Ÿโ”คส‚โ•Ÿโ”คส‚โ•Ÿโ”คโŒ‘โ•Ÿโ•ขโ•‘
โ””โ”ค+โ•Ÿโ”˜โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•šโ•
 โ•˜โ•คโ•

= 5 + 5.

42 (170 bytes in UTF-16)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ”Œโ”€โ•–โ•”โ•—
โ”‚โ”Œโ”€โ•–โ”Œโ”€โ•–โ”œโ”ค!โ•Ÿโ”คโ™ฏโ•Ÿโ”คษ•โ•Ÿโ”คส‚โ•Ÿโ”คโŒ‘โ•Ÿโ•ขโ•‘
โ””โ”คโ™ฏโ•Ÿโ”คร—โ•Ÿโ”˜โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•˜โ•โ•โ•šโ•
 โ•˜โ•โ•โ•˜โ•คโ•

= 6 ร— (6 + 1).

Racket 205 bytes

(- pi pi)
(/ pi pi)
(/(+ pi pi)pi)
(floor pi)
(ceiling pi)
(sub1(floor(+ pi pi)))
(floor(+ pi pi))
(ceiling(+ pi pi))
(floor(sub1(* pi pi)))
(floor(* pi pi))
(ceiling(* pi pi))
(floor(+ pi pi(expt pi pi)))

Output:

0.0
1.0
2.0
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
42.0

Haskell, 212 210 198 196 190 187 134 bytes

Edit: After reading in the FAQ that using pi is allowed, throwing everything away and doing it all using pionly saves a lot of bytes.

pi-pi                     -- 0.0,  5 bytes
pi/pi                     -- 1.0,  5 bytes
succ$pi/pi                -- 2.0, 10 bytes
floor pi                  --   3,  8 bytes
ceiling pi                --   4, 10 bytes
succ.ceiling$pi           --   5, 15 bytes
floor$pi+pi               --   6, 11 bytes
ceiling$pi+pi             --   7, 13 bytes
pred.floor$pi*pi          --   8, 16 bytes
floor$pi*pi               --   9, 11 bytes
round$pi*pi               --  10, 11 bytes
floor$pi**pi+pi+pi        --  42, 18 bytes

However, I still like the old approach more as using a number to generate other numbers feels a bit like cheating.

sum[]                     --  0,  5 bytes
length[LT]                --  1, 10 bytes
fromEnum GT               --  2, 11 bytes
length[LT ..]             --  3, 13 bytes
length$show[()]           --  4, 15 bytes
length.show$False         --  5, 17 bytes
length$show[True]         --  6, 17 bytes
length.show$Left()        --  7, 18 bytes
length.show$Right()       --  8, 19 bytes
length$show[Just[]]       --  9, 19 bytes
length$show[LT ..]        -- 10, 18 bytes
fromEnum.succ.last$show() -- 42, 25 bytes

LT,EQ and GT are the values of the Ordering Type. As Ordering is an instance of Enum, fromEnum GT yields 2 and [LT ..] creates the list [LT,EQ,GT]. show converts all instances of the Show type class to strings.

Bonus:
42 in 42 bytes: length.show$Just$[LT ..]>>[EQ,GT]>>[GT,LT]
How long is nothing? length Nothing

Saved 3 bytes thanks to nimi and 3 bytes thanks to xnor.

Perl 5, 86 75 71 66 bytes

All ^Fs are literal control characters (0x06 in ASCII), and hence a single byte.

$[          # array start index, defaults to 0                                  2
!$[         # !0 is 1                                                           3
$^F         # max sys file descriptor number, 2 on all sane systems             2
++$^F       # 2 + 1                                                             4
~-$]        # 5 - 1                                                             4
int$]       # $] is Perl version, int truncates                                 5
length$~    # 1 + 5                                                             8
~~exp$^F    # floor(e^2)                                                        7
$^F<<$^F    # 2 bitshift-right 2                                                6
-!$[+ord$/  # -1 + 10                                                          10
ord$/       # input record separator, newline by default, ord gets ASCII val    5
ord($"^$/)  # 32 + 10                                                          10

Thanks to msh210 for saving 11 bytes and Dom Hastings for 9 bytes!

Haskell, 133 bytes

Pi-based, three floating point answers with the rest being integers:

 0: (5)  pi-pi
 1: (5)  pi/pi
 2: (10) (pi+pi)/pi
 3: (8)  round pi
 4: (10) ceiling pi
 5: (15) succ.ceiling$pi
 6: (11) floor$pi+pi
 7: (13) ceiling$pi+pi
 8: (16) floor$cosh pi-pi
 9: (11) floor$pi*pi
10: (11) round$pi*pi
42: (18) floor$pi**pi+pi+pi

Mouse-2002, 27 26 17 14 bytes

The first snippets push 0-10, and ZR+ pushes 25 then 17 and 25 17 + 42 = is 1.

A
B
C
D
E
F
G
H
I
J
K
ZR+

Jelly, 26 bytes (non-competing)

00: 
01: โ€˜
02: โ€˜โ€˜
03: โ€˜โ€˜โ€˜
04: โ€˜โ€˜แธค
05: โตH
06: โตHโ€˜
07: โดHโ€™
08: โดH
09: โตโ€™
10: โต
42: โดแธค+โต

Try it online! (paste each one of the snippets in the 'Code' field.)

DC, 35 bytes

K
KZ
IZ
Iv
EI-
FI-
IZd*
IIZ/
Ivd+
IIv-
IIZ-
IKZ-
I
EdE++

To test the snippets append a f to print the stack and pass that string to dc:

$ echo 'EdE++f' | dc
42

BASH, 318 bytes

0 to 3 are exit code, other ones are stored in A

bytes count is split as follow :2-5-5-26-23-32-26-38-26-33-32-70

#0
ls
#1
cd \\
#2
ls \\
#3
cd \\
A=$?
A=$(($A+$A+$A))
#4
ls \\
A=$?
A=$(($A*$A))
#5
cd \\
A=$?
A=$(($A+$A+$A+$A+$A))
#6
ls \\
A=$?
A=$(($A+$A+$A))
#7
cd \\
A=$?
A=$(($A+$A+$A+$A+$A+$A+$A))
#8
ls \\
A=$?
A=$(($A*$A*$A))
#9
A=$?
A=$(($A+$A+$A))
#10
ls \\
A=$?
A=$(($A+$A+$A+$A+$A))
#42
@
A=$?
cd \\
B=$?
cd \\
C=$?
C=$(($C+$C+$C))
B=$(($A-$B))
A=$(($B/$C))

7 is more than probably golfable a bit more, as is 42

Perl6 (117 112) no state

e-e
e/e
e.floor
e.round
pi.ceiling
floor e+e
tau.floor
tau.ceiling
floor pi*e
floor pi*pi
round pi*pi
tau.floor*tau.ceiling

Hexagony, 13 bytes


1
2
3
4
5
6
7
8
9
10
42

Try it online!

In Hexagony, 0 through 9 are functions that multiply the current memory by 10, and then add the number represented by the function name. Therefore, the first snippet is empty as memories start off as 0.

For example, if the current memory is 65, executing the function 3 will make the current memory 653.

(To downvoters: downvote all you want; I am ready.)

C, 78 bytes

Quite a handful of undefined behaviours.

The implementation is gcc (GCC) 5.3.1 20151207 (Red Hat 5.3.1-2), using this online C sandbox.

a-a                //1-1
a                  //1
a+a                //1+1
a+a+a              //1+1+1
++a*a              //2*2
++a+a++            //3+2
++a*a++            //3*2
a+++a+a+a          //1+2+2+2
++a<<a             //2<<2
++a*++a            //3*3
a+++a*++a          //1+3*3
(a=++a*a++)*a+a    //(a=3*2)*a+a

a defaults to 1 being the first argument of main.

Boilerplate example for the last one:

#include <stdio.h>
int main(int a)
{
    printf("%d\n",(a=++a*a++)*a+a);
    return 0;
}

without undefined behaviors, 88 bytes

a-a              //1-1
a                //1
a+a              //1+1
a+a+a            //1+1+1
a<<a+a           //1<<2
a<<a+a|a         //(1<<2)|1
a+a+a<<a         //3<<1
a+a+a<<a|a       //(3<<1)|1
a+a<<a+a         //2<<2
a+a<<a+a|a       //(2<<2)|1
a++;a<<a|a       //(2<<2)|2
a=a+a+a<<a;a*a+a //a=3<<1;a*a+a

J, 46 43 42 bytes

Thanks to Nแดฎแถป for the help and exploration!

%_         NB. Inverse of infinity
_.         NB. Indeterminate value, evaluates to 1
2:_
3:_
4:_
5:_
6:_
7:_
8:_
9:_
+~5:_      NB. verb magic
(7:*6:)_   NB. 7 * 6

Here are some other programs:

(number): (representation)
1:  *_             NB. signum of infinity                                          same bytes
1:  #a:            NB. The tally of the Ace/Empty box                              +1 byte
1:  1:_            NB. The constant function with infinity;                        +1 byte
2:  #_`_           NB. The tally of infinity gerund-ed with itself                 +1 byte
2:  #_,_           NB. (same)                                                      +1 byte
2:  #_;_           NB. (same)                                                      +1 byte
42: (*:+])6:_      NB. verb magic / 6 squared plus 6                               +1 byte
42: +:<.o.7:_      NB. double floor pi times 7                                     +1 byte
42: <.(#a.)%6:_    NB. Tally of alphabet (256) divided by 6 (6:_) floored (<.);    +3 bytes
42: a+*~(a=:6:_)   NB. 6 squared plus 6.                                           +4 bytes
42: (a=:6:_)+:*a   NB. 6 squared plus 6.                                           +4 bytes
42: #C.>.%:^@^2:_  NB. I'm not entirely sure how this works                        +5 bytes

Ruby, 194 bytes

[]<=>[]
[[]].size
[[],[]].size
Dir.name.size
Hash.name.size
Float.name.size
Method.name.size
Integer.name.size
NilClass.name.size
TrueClass.name.size
FalseClass.name.size
Integer.name.size*Method.name.size

DUP, 68 bytes

[
 [
  [
[)]!
[ )]!
[  )]!
[)~_]!
[ )~_]!
[  )~_]!
[   )~_]!
[)$+]!
[ )$+~_$+]!

Try it here.

There are a LOT of ways to do this, but I'm abusing the return stack for this one.

Explanation

To fully figure this out, you need to understand DUP's behavior regarding lambdas. Instead of pushing the lambda itself to the stack, it actually pushes the current IP to the stack when the lambda is detected. That can explain the first 3 snippets, which involve lambdas.

The next snippets use the return stack. When ! is executed, the current IP is pushed to the return stack, and the top of the stack is set as the new IP to start lambda execution. ) pops a number from the return stack onto the data stack.

That's pretty much enough to explain the rest of the snippets. If you still don't get it, keep in mind that the Step button is quite handy!

Jolf, 26 bytes

<empty>
lฮญ
lq
mfฯ€
Uฮฌ
ยฝt
mfฯ„
mฮ“Ct
wwt
wt
t
mQ

Okay, so I have a 42-builtin. I'm obsessed with that number. Also for forty-two, lm,t: the length of the integer partitions of ten.

Explanations

The empty program is a truth machine, and, since given no input, just output's a zero.

lฮญ is the length of a tab, i.e., 1.

lq is the length of the source code, i.e., 2.

mfฯ€ is the floor of pi, i.e., 3.

Uฮฌ is the square root of 16, i.e., 4.

ยฝt is half ten, i.e., 5.

mfฯ„ is the floor of tau (i.e. twice pi), i.e., 6

mฮ“Ct is the length of the collatz sequence beginning with ten, i.e. 7.

wwt is 10-1-1, i.e., 8.

wt is 10-1, i.e., 9.

t is 10.

mQ is the builtin for 42.


Alternate solution

Except for 0 and 10, a solution with @<char with charcode value of N> would be golfier solution for N, however, even though it doesn't use any literals (it actually reads the source code's next character), it isn't in the spirit of the challenge. This would tally 20 bytes.

Cardinal, 50 bytes

Instructions, with alternatives if they have the same lengths:

0:  IPs are initialized to 0, otherwise, use instruction 0
1:  +
2:  ++
3:  +++
4:  ++++     or ++=*    or ++=t
5:  +++++    or ++=t+   or ++=*+
6:  +++=*    or ++=**
7:  +++=*+   or ++=tt-
8:  ++=tt
9:  +++=t
10: ++=tt*   or +++=t+
42: +++=*=t*

Explanation:

IPs in Cardinal carry length 2 stacks around. The topmost value is called active, the bottom value is called passive. Both can switch roles.

+ increment active value
- decrement active value
* addition : active=active+passive
t multiplication: active=active*passive
= set passive = active value

Staq, 60 bytes

&              0
&i             1
&ii            2
&iii           3
&iiq           4
&iiqi          5
&iiqii         6
&iiiqdd        7
&iiiqd         8
&iiiq          9
&iiiqi        10
&iiqii&+qX+   42

Instructions:

& push 0 on top of stack
i increment top stack value
d decrement top stack value
q square top stack value
+ add top and 2nd stack values, put sum on top of stack
X delete 2nd stack value

beeswax, 50 46 bytes

(62 57 bytes, if IPs are not initialized)

Explanation of instructions:

P    increment top lstack value
M    decrement top lstack value
z    all lstack values = 0
F    all lstack values = top
G    get value from absolute(row,column) = lstack(2nd,3rd) value.
@    flip 1st and 3rd lstack values
.    top=top*2nd value
+    top=top+2nd value
!    bitwise NOT
(bel) ASCII control character 7, not printable

Instructions for number creation without using numbers, with multiple examples, if the byte lengths are the same. Prepend z if the bee is not in an initialized state:

 initialized  to 0                         not initialized to 0
                                                  prepend z
no instruction              [0,0,0]โ€ข       z
P                           [0,0,1]โ€ข       zP
PP                          [0,0,2]โ€ข       zPP
PPP                         [0,0,3]โ€ข       zPPP
PPF. or PPPP or PPF+        [0,0,4]โ€ข       zPPF.
PPF.P or PPF+P or PPPPP     [0,0,5]โ€ข       zPPF.P
PPPF+ or PPF++ or PPFP.     [0,0,6]โ€ข       zPPPF+
PPPF+P or PPF..M            [0,0,7]โ€ข       zPPF..M
(bel)*1FG                   [0,0,7]โ€ข  โ† this would make โ€˜7โ€™ one byte shorter
PPF..                       [0,0,8]โ€ข       zPPF..
PPPF.                       [0,0,9]โ€ข       zPPPF.
PPPF.P                      [0,0,10]โ€ข      zPPPF.P
*PFG                        [0,0,42]โ€ข      *PFG (in this configuration the IP is always initialized)

You can clone my beeswax GitHub repository here.

JavaScript, 144 141 140 138 132 125 123 bytes

With help from @edc65, @Sjoerd Job Postmus, @DocMax, @usandfriends, @Charlie Wynn and @Mwr247!

result.textContent = [

+[]                          ,// 0  (3 bytes)
-~[]                         ,// 1  (4 bytes)
-~-~[]                       ,// 2  (6 bytes)
-~-~-~[]                     ,// 3  (8 bytes)
-~Math.PI                    ,// 4  (9 bytes)
-~-~Math.PI                  ,// 5  (11 bytes)
-~-~-~Math.PI                ,// 6  (13 bytes)
Date.length                  ,// 7  (11 bytes)
(a=-~-~[])<<a                ,// 8  (13 bytes) = (2 << 2)
(a=~Math.E)*a                ,// 9  (13 bytes) = (-3 * -3)
(a=-~-~[])<<a|a              ,// 10 (15 bytes) = ((2 << 2) | 2)
(a=Date.length)*--a           // 42 (19 bytes) = (7 * 6)

];
<pre id="result"></pre>

PowerShell, 147 bytes

These use + to implicitly cast things to integers. The later numbers use Enums from the .Net Framework unerpinnings of PowerShell which happen to have the right values.

+$a                          #0, 3 bytes (unset vars are $null, +$null == 0)
+$?                          #1, 3 bytes (bool previous result, default $true, +$true == 1)
$?+$?                        #2, 5 bytes (same as #1, twice)
$?+$?+$?                     #3, 8 bytes (beats [Int][Math]::E)
$?+$?-shl$?                  #4, 11 bytes (-shl is shift-left)
$?+$?+$?+$?+$?               #5, 14 bytes
$?+$?+$?-shl$?               #6, 14 bytes (enum value, + casts to integer)
+[TypeCode]::Int16           #7, 18 bytes
$?+$?-shl$?+$?               #8, 14 bytes
+[consolekey]::tab           #9, 18 bytes
+[TypeCode]::UInt32          #10, 19 bytes
+[consolekey]::Print         #42, 20 bytes

#Total:                      147 bytes

Hoon, 89 bytes

`@`&
`@`|
+(|)
+:!=(+)
+:!=(-<)
+:!=(->)
+:!=(+<)
+:!=(+>)
+:!=(-<-)
+:!=(-<+)
+:!=(->-)
+:!=(->->-)

0 is just "yes" (0) casted to an atom

1 is just "no" (1) casted to an atom

2 is incremented "no" - .+ automatically casts to an atom, so no need for @

3 - 42 are the fun ones: It's using the != rune, which compiles an arbitrary Hoon expression to Nock. In this case, it's compiling axis navigation syntax into the Nock expression [0 axis], which I then take the tail of with +:expr.

In Hoon, all variable accesses are actually just indexing into a binary tree, and it allows you to index manually as well. The syntax is alternating sets of -/+ and </>, each one being head/tails for the current node. I also use +axis, which is a bit shorter for 8, 9, and 42.

R, 100 bytes

Copied the solutions for 6 and 7 from @MiloChen here.

+F                   # | 0     | 2 bytes
+T                   # | 1     | 2 bytes
T+T                  # | 2     | 3 bytes
T+T+T                # | 3     | 5 bytes
T+T+T+T              # | 4     | 7 bytes
T+T+T+T+T            # | 5     | 9 bytes
nrow(BOD)            # | 6     | 9 bytes
cars$s[pi]           # | 7     | 10 bytes
cars$s[pi]+T         # | 8     | 12 bytes
(pi*pi)%/%T          # | 9     | 11 bytes
(pi*pi)%/%T+T        # | 10    | 13 bytes
(pi^pi+pi+pi)%/%T    # | 42    | 17 bytes
                     # | total | 100 bytes

This saves some bytes compared to the 123 and 165 solutions.

MS Excel formulas, 163 151 150 143 bytes

Not exactly a programming language, but here it goes...

0:  -Z9                         (03 bytes)
1:  N(TRUE)                     (07 bytes)
2:  TYPE(T(Z9))                 (11 bytes)
3:  TRUNC(PI())                 (11 bytes)
4:  TYPE(TRUE)                  (10 bytes)
5:  ODD(PI())                   (09 bytes)
6:  FACT(PI())                  (10 bytes)
7:  ODD(PI()+PI())              (14 bytes)
8:  EVEN(PI()+PI())             (15 bytes)
9:  TRUNC(PI()*PI())            (16 bytes)
10: EVEN(PI()*PI())             (15 bytes)
42: EVEN(CODE(-PI())-PI())      (22 bytes)

PI() is used in most cases as it is the shorter way (that I am aware of) to introduce a numeric value without using a number or string literal. N converts various things (incl. booleans) to numbers, and T converts various things to text. TYPE returns 2 for a text argument and 4 for a boolean argument. TRUNC discards fractional part (i.e. rounds positive numbers down), EVEN rounds up to the next even number, and ODD rounds up to the next odd number. CODE(-PI()) is the ASCII code of the first character of the conversion to text of -ฯ€, i.e. 45 (for "-").

EDIT: Removed equal signs from the byte count (-12!) - as pointed out by Nแดฎแถป in the comments, they are not supposed to be included.

EDIT 2: Assuming the rest of the worksheet is empty, it is possible to use a reference to an empty cell as zero (again, suggested by Nแดฎแถป) provided that we include a minus sign (or use it in other numeric expression) to resolve type ambiguity.

Jelly, 31

<blank>
โ€˜
โ€˜โ€˜
โ€˜โ€˜โ€˜
โ€˜โ€˜ยฒ
โ€˜โ€˜ยฒโ€˜
โ€˜โ€˜โ€˜แธค
โดHโ€™
โดH
โ€˜โ€˜โ€˜ยฒ
โต
โดแธคโต+

Explanation

0: Outputs 0 by default

  1. Increment
  2. Increment twice
  3. Increment thrice
  4. Increment twice and square
  5. Increment twice, square, and increment
  6. Increment thrice and double
  7. Halve sixteen and decrement
  8. Halve sixteen
  9. Increment thrice and square
  10. Ten

42: Double sixteen and add ten

C#, no usings, 234 bytes

new int()                       // 0
-~new int()                     // 1
-~-~new int()                   // 2
-~-~-~new int()                 // 3
-~-~-~-~new int()               // 4
-~-~-~-~-~new int()             // 5
-~-~-~-~-~-~new int()           // 6
-~-~-~-~-~-~-~new int()         // 7
-~-~-~-~-~-~-~-~new int()       // 8
(int)System.ConsoleKey.Tab      // 9
(int)System.TypeCode.UInt32     // 10
(int)System.ConsoleKey.Print    // 42

This is much more boring than I initially thought it was going to be. I had pretty varied ideas, such as new[]{true}.Length and true.GetHashCode() and typeof(int).Name.Length and uint.MinValue etc., but new int() beat them all.

Visual Basic for Applications, no named constants, 134 bytes

That's tougher:

-x                     '=0  (2 bytes)
x^x                    '=1  (3 bytes)
x^x+x^x                '=2  (7 bytes)
x^x+x^x+x^x            '=3  (11 bytes)
Len(Year(x))           '=4  (12 bytes)
Len(Year(x)&-x)        '=5  (15 bytes)
Day(x)Mod Month(x)     '=6  (18 bytes)
Len(Time())-x^x        '=7  (15 bytes)
Len(Time())            '=8  (11 bytes)
Len(Time()&-x)         '=9  (14 bytes)
Len(Date())            '=10 (11 bytes)
Day(x)+Month(x)        '=42 (15 bytes)

Total = 134 bytes. Again, - and ^ force undeclared variables (Variants) to be treated as numeric, and in VBA 0^0 evals to 1.

The concatenation operator force numbers to string form, so -x is 0 and &-x is & "0".

For Day, Month and Year functions, zero corresponds to december 31, 1899.

I also used the fact that (at least for most locales), VBA date strings have 10 characters and time strings have eight...

Thanks! This was a funny challenge.

Dyalog APL, 59 52 bytes

-7 bytes by @NBZ

I wasn't about to let one of @NBZ's questions go without an APL answer!

โดโฌ            0
โŽ•IO           1
โดโŽ•SD          2
โŽ•WX           3
โดโŽ•AI          4
โŒˆโŸโŽ•PW         5
โŒŠโŸโŽ•FR         6
โดโŽ•TS          7
+โจโดโŽ•AI        8
โŒŠโ—‹โ—‹โŽ•IO        9; floor(pi^2 times โŽ•IO)
โดโŽ•D           10
โŽโŒฝโ•โŒˆ*โ—‹โ‰ข#    42

In the last snippet, by NBZ, โ‰ข# equals 1. ceil(e^(pi*1)) is calculated as 24, whose digits are then swapped.

Constants used:

Haskell, 295 bytes

0: length[]
1: length[()]
2: length[(),()]
3: length[(),(),()]
4: length[(),(),(),()]
5: length[(),(),(),(),()]
6: length[(),(),(),(),(),()]
7: length[(),(),(),(),(),(),()]
8: length[(),(),(),(),(),(),(),()]
9: length[(),(),()]*length[(),(),()]
10: length[(),()]*length[(),(),(),(),()]
42: length[(),(),(),(),(),()]*length[(),(),(),(),(),(),()]

Perl 6, 84 81 bytes

+$           #  0 
++$          #  1
-+^++$       #  2
-+^e         #  3
-+^ฯ€         #  4
1+-+^ฯ€       #  5
floor ฯ„      #  6
-+^ฯ„         #  7
floor e*ฯ€    #  8
floor ฯ€*ฯ€    #  9
-+^(ฯ„+e)     # 10
-+^(e**e*e)  # 42

Constants used

> e
2.71828182845905
> ฯ€
3.14159265358979
> ฯ„
6.28318530717959

An attempt at some explanation

#0: $ is an anonymous state variable, the + coerces it to a number, and by default its value is 0
#1: ++$ increases the state var by 1, giving us 1
#2: +^ as a prefix is the Integer bitwise negation operator, use that with ++$ (1) and we get -2, use - to negate it and give 2
#3: Use +^ with e, which is coerced to Int, giving -3 which then gets negated with -
#4: Same as #3 but with ฯ€
#5: Same as #4 but add 1
I think the rest are easy to follow with the above bits explained.

Visual Basic for Applications, 68 bytes

VBA has a lot of builtin constants and public enums. I opted not to use any external or MS Office-specific library - only base VBA:

-x                     '=0  (2 bytes)
x^x                    '=1  (3 bytes)
vbGet                  '=2  (5 bytes)
vbLong                 '=3  (6 bytes)
vbLet                  '=4  (5 bytes)
vbDouble               '=5  (8 bytes)
vbYes                  '=6  (5 bytes)
vbNo                   '=7  (4 bytes)
vbSet                  '=8  (5 bytes)
vbObject               '=9  (8 bytes)
vbError                '=10 (7 bytes)
vbKeyPrint             '=42 (10 bytes)

Total = 68 bytes. Notice that by default, undeclared variables (such as x above) are all set to blank Variants, that may be interpreted, depending on context, as 0 or as an empty string. However, both operators - and ^ force it to be numeric. Also, in VBA, 0^0 is evaluated to 1 (instead of generating an error as one might expect). I'll also post an answer without constants.

80386 machine code, 73 bytes

Hexdump:

33 c0
33 c0 40
33 c0 40 40
33 c0 40 40 40
33 c0 40 40 40 40
33 c0 40 8d 04 80
33 c0 40 8d 04 80 40
33 c0 40 8d 04 80 40 40
33 c0 40 8d 04 c0 48
33 c0 40 8d 04 c0
33 c0 40 8d 04 c0 40
33 c0 40 8d 04 c0 8d 04 80 48 48 48

The snippets calculate the required value in the eax register, suitable as a return value from a function.

I used various combinations of the following instructions:

xor eax, eax         (33 c0)    eax = 0
inc eax              (40)       eax = eax + 1
dec eax              (48)       eax = eax - 1
lea eax, [eax+eax*4] (8d 04 80) eax = eax * 5
lea eax, [eax+eax*8] (8d 04 c0) eax = eax * 9

The numbers here are too small to use all the possibilities of the instruction set - the only noteworthy thing here is the easy multiplication by 5 and 9. For example, here is a 13-byte snippet whose result is 2016:

33 c0      xor eax, eax             eax = 0
40         inc eax                  eax = 1
8d 0c c0   lea ecx, [eax+eax*8]     ecx = 9
8d 04 89   lea eax, [ecx+ecx*4]     eax = 45
f7 e0      mul eax                  eax = 2025
2b c1      sub eax, ecx             eax = 2016

R, 166 165 bytes

I made a PI based answer

pi-pi                         # 0
pi/pi                         # 1
(pi+pi)/pi                    # 2 
floor(pi)                     # 3 
ceiling(pi)                   # 4 
ceiling(pi)+pi/pi             # 5 
floor(pi+pi)                  # 6 
ceiling(pi+pi)                # 7 
floor(pi*pi)-pi/pi            # 8 
floor(pi*pi)                  # 9 
ceiling(pi*pi)                # 10 
ceiling(pi^pi+pi+sqrt(pi))    # 42

Math++, 92 bytes total

0 (1 bytes): a

1 (2 bytes):!a

2 (3 bytes):_$e

3 (4 bytes): _$pi

4 (7 bytes): _$e+_$e

5 (8 bytes): _($e+$e)

6 (9 bytes): _$pi+_$pi

7 (8 bytes): _($e*$e)

8 (9 bytes): _($e*$pi)

9 (10 bytes): _($pi*$pi)

10 (12 bytes): _$e*_($e+$e)

42 (19 bytes): _($pi+$pi)*_($e*$e)

><>, 86 bytes

Relies on stack size to get its literals.

dc, 42 bytes

K
zz
OZ
zzz+
OZd*
OdZ/
zzzz*
Ozz+-
OdZ-
Oz-
O
Od+dz++

Results

0
1
2
3
4
5
6
7
8
9
10
42

There aren't many ways to generate new numbers with dc. I use O: output base, initially 10; K: precision, initially 0; z stack depth, initially 0; Z significant digits of operand. We combine these with the usual arithmetic operators.

Test program

#!/bin/bash

progs=(                                         \
    "K"                                         \
    "zz"                                        \
    "OZ"                                        \
    "zzz+"                                      \
    "OZd*"                                      \
    "OdZ/"                                      \
    "zzzz*"                                     \
    "Ozz+-"                                     \
    "OdZ-"                                      \
    "Oz-"                                       \
    "O"                                         \
    "Od+dz++"                                   \
)

a=0
results=()
for i in "${progs[@]}"
do
    results+=($(dc -e "${i}p"))
    (( a+=${#i} ))
done

echo "#dc, $a bytes"
echo
printf '    %s\n' "${progs[@]}"
echo
echo '##Results'
echo
printf '    %s\n' "${results[@]}"

๐”ผ๐•Š๐•„๐•š๐•Ÿ, 36 bytes (12 chars)

แธ€
แธ
แธ‚
แธƒ
แธ„
แธ…
แธ†
แธ‡
แธˆ
แธ‰
แธŠ
แธช

Try it here (test-suite-style, Firefox only).

There are variables for numbers from 0-256. (One of the benefits of choosing from UTF-8 is that you can dedicate a whole charset of 256 characters just to this kind of stuff. (Of course, byte count is a side effect.))

Python 2, 191 159 158 157 156 149 146 bytes

My first submission ever, I hope I got everything right ! Based on the time I spent on this, I guess there's surely a better one for a few of them.

# 0 | Bytes : 5
int()

# 1 | Bytes : 5
+True

# 2 | Bytes : 6
-~True

# 3 | Bytes : 8
-~-~True

# 4 | Bytes : 10
-~-~-~True

# 5 | Bytes : 12
-~-~-~-~True

# 6 | Bytes : 14
-~-~-~-~-~True

# 7 | Bytes : 16
-~-~-~-~-~-~True

# 8 | Bytes : 15
a=True;a<<a+a+a

# 9 | Bytes : 19
a=True;(a<<a+a+a)+a

# 10 | Bytes : 20
int(`+True`+`int()`)

# 42 | Bytes : 16
~-len(`license`)
# Especially proud of this one !

Total byte count: 146

Many thanks to FryAmTheEggman !

Seriously, 39 33 bytes

Stuff in parentheses is explanations:

 (single space, pushes size of stack, which is 0 at program start)
 u (space pushes 0, u adds 1 (1))
 โŒ (space pushes 0, โŒ adds 2 (2))
 uโŒ (space pushes 0, u adds 1 (1), โŒ adds 2 (3))
 โŒโŒ (space pushes 0, โŒโŒ adds 2 twice (4))
 โŒP (space pushes 0, โŒ adds 2 (2), P pushes the 2nd prime (5))
Hlโ–“ (H pushes "Hello, World!", l pushes length (13), โ–“ pushes pi(13) (6))
QlP (Q pushes "QlP", l pushes length (3), P pushes the 3rd prime (7))
Qlโ•™ (Q pushes "QlP", l pushes length (3), โ•™ pushes 2**3 (8))
รบlโ–“ (รบ pushes the lowercase English alphabet, l pushes length (26), โ–“ pushes pi(26) (9))
 uโ•ค (space pushes 0, u adds 1 (1), โ•ค pushes 10**1 (10))
HlPD (H pushes "Hello, World!", l pushes length (13), P pushes the 13th prime (43), D subtracts 1 (42))

Hexdumps of programs:

20
2075
20a9
2075a9
20a9a9
20a950
486cb2
516c50
516cd3
a36cb2
2075d1
486c5044

Thanks to quintopia for 6 bytes!

R, 123 bytes

+!pi                #  0  -   4 bytes
+TRUE               #  1  -   5 bytes
nchar(NA)           #  2  -   9 bytes
floor(pi)           #  3  -   9 bytes
cars$d[pi]          #  4  -  10 bytes
ncol(CO2)           #  5  -   9 bytes
nrow(BOD)           #  6  -   9 bytes
cars$s[pi]          #  7  -  10 bytes
sum(dim(BOD))       #  8  -  13 bytes
floor(pi*pi)        #  9  -  12 bytes
ceiling(pi*pi)      # 10  -  14 bytes
nrow(CO2)/nchar(NA) # 42  -  19 bytes
                    # Total 123 bytes

C, 202 bytes

enum{a}; // 0, 8

enum{a,b}; // 1, 10

enum{a,b,c}; // 2, 12

enum{a,b,c,d}; // 3, 14

enum{a,b,c,d,e}; // 4, 16

enum{a,b,c,d,e,f}; // 5, 18

enum{a,b,c,d};c*d; // 6, 18

enum{a,b,c,d,e};d+e; // 7, 20

enum{a,b,c};c<<c; // 8, 17

enum{a,b,c};b+(c<<c); //  9, 21

enum{a,b,c};c+(c<<c); // 10, 21

enum{a,b,c,d,e,f};c*f*e+c; // 42, 26

Printed Version, 730 bytes

enum{a,b,c,d,e};char m[d]={(d<<e)+a,a};main(){printf(m);} // 0, 57

enum{a,b,c,d,e};char m[d]={(d<<e)+b,a};main(){printf(m);} // 1, 57

enum{a,b,c,d,e};char m[d]={(d<<e)+c,a};main(){printf(m);} // 2, 57

enum{a,b,c,d,e};char m[d]={(d<<e)+d,a};main(){printf(m);} // 3, 57

enum{a,b,c,d,e};char m[d]={(d<<e)+e,a};main(){printf(m);} // 4, 57

enum{a,b,c,d,e};char m[d]={(d<<e)+e+b,a};main(){printf(m);} // 5, 59

enum{a,b,c,d,e};char m[d]={(d<<e)+e+c,a};main(){printf(m);} // 6, 59

enum{a,b,c,d,e};char m[d]={(d<<e)+e+d,a};main(){printf(m);} // 7, 59

enum{a,b,c,d,e};char m[d]={(d<<e)+e+e,a};main(){printf(m);} // 8, 59

enum{a,b,c,d,e,f};char m[d]={(d<<e)+f+e,a};main(){printf(m);} // 9, 61

enum{a,b,c,d,e,f,g,h,i,j,k};char m[d]={k*d+h,k*k,a};main(){printf(m,k);} // 10, 72

enum{a,b,c,d,e,f,g,h,i,j,k};char m[d]={k*d+h,k*k,a};main(){printf(m,k*e+c);} // 42, 76

PHP, 157 145 91 bytes

First time posting on Code Golf, figured I'd give it a shot. I'll get better eventually :P If you see any obvious (to you) spots where I could save characters, let me know.

EDIT: Realized I didn't need the semicolons, since these are just snippets.

EDIT2: Thanks to Blackhole for many suggestions!

LC_ALL
DNS_A
~~M_E
~~M_PI
LOCK_NB 
LC_TIME
LOG_INFO
INI_ALL
IMG_WBMP
SQL_DATE
SQL_TIME
LOG_INFO*INI_ALL

Prolog, 113 99 bytes

Snippets:

e-e              % 0.0
e/e              % 1.0
e/e+e/e          % 2.0
ceil(e)          % 3
ceil(pi)         % 4
ceil(e*e-e)      % 5
ceil(e+e)        % 6
floor(e*e)       % 7
ceil(e*e)        % 8
ceil(pi*e)       % 9
ceil(pi*pi)      % 10
ceil(e^e*e)      % 42

Combines the mathematical constants e and pi in different ways converted to int.

Edit: Saved 14 bytes by utilizing floats for 0-2.

Javascript (Browser Env), 155 136 130 bytes

+[]
-~[]
-~-~[]
-~-~-~[]
-~-~-~-~[]
-~-~-~-~-~[]
-~-~-~[]<<-~[]
-~-~-~-~-~-~-~[]
-~[]<<-~-~-~[]
~(~[]+[]+-[])
-~[]+[]+-[]
-~(top+top.s).length // Requires browser environment

Thanks to:
@Ismael Miguel: 155 -> 136 -> 130 bytes

Pyth, 35 34 33 bytes

-1 byte by @Mimarik

There are a number of possibilities for some programs.

0, 1 byte

Z

1, 2 bytes

hZ
!Z

2, 3 bytes

hhZ
eCG
eCd
lyd
lyb
lyN

3, 3 bytes

l`d

4, 3 bytes

l`b
eCN

5, 4 bytes

hl`b
telG

6, 3 bytes

elG

7, 4 bytes

tttT
helG

8, 3 bytes

ttT

9, 2 bytes

tT

10, 1 byte

T

42, 4 bytes

yhyT

All of these involve either basic double (y), +1 (h) and -1 (t) commands, or l (length of a string). The Z variable is initialized to zero.

For 5, b is initialized to a newline character. Backtick gives "\n" (including the quotes, and the length of that string is 4.

Try them here!

Marbelous, 98 bytes

Not terribly exciting, it relies on the ?n devices which turn any marble into a random value in the range 0..n (inclusive) a side effect of this is that ?0 turns any marble into a 0 regardless of input. I think the use of literals is permitted because the value does not affect the outcome and there is no other way to call a function once in Marbelous.

0:

00  # A hexadicemal literal: value 0
?0  # Turn any marble into a random value from the range 0..0 (inclusive)

1:

00
?0
+1  # increment by one

...

9:

00
?0
+9

10:

00
?0
+A  # increment by 10

42:

00
?0
+L  # increment by 21
+L

Pyth, 50 40 bytes

Z
hZ
hhZ
hhhZ
hhhhZ
hhhhhZ
ttttT
tttT
ttT
tT
T
yhyT

In Pyth, Z=0 and T=10. h is head, which means the next variable + 1. (e.g. hhZ == 2). t is tail, which means the next variable - 1 (e.g. tttT == 7). The last line is the fanciest: we essentially do double(1 + double(10)).

Try it out here!

Thomas Kwa has golfed a superior solution.

Python 2, 306 275 274 bytes

I used the fact that for any x (integer and not 0) the expression x/x equals 1 and played around with some bitwise operations.

I adjusted the snippets such that they still meet the requirements (thanks @nimi this saved me 24 bytes), but you have to manually test them. Here is the code and individual byte counts:

zero.py Bytes: 7
len({})
--------------------------
one.py  Bytes: 12
r=id(id)
r/r
--------------------------
two.py  Bytes: 17
r=id(id)
-(~r/r)
--------------------------
three.py    Bytes: 20
r=id(id)
-(~r/r)|r/r
--------------------------
four.py Bytes: 20
r=~id(id)/id(id)
r*r
--------------------------
five.py Bytes: 26
r=~id(id)/id(id)
(r*r)|r/r
--------------------------
six.py  Bytes: 25
r=~id(id)/id(id)
(r*r)|-r
--------------------------
seven.py    Bytes: 27
r=~id(id)/id(id)
-~(r*r|-r)
--------------------------
eight.py    Bytes: 24
r=-(~id(id)/id(id))
r<<r
--------------------------
nine.py Bytes: 29
r=-(~id(id)/id(id))
r-~(r<<r)
--------------------------
ten.py  Bytes: 31
r=~id(id)/id(id)
-r*((r*r)|r/r)
--------------------------
answer.py   Bytes: 37
r=-(~id(id)/id(id))
(r<<r*r)|(r<<r)|r
--------------------------
Total byte count: 274

k4, 41 bytes

Most of this is a cheap hackโ€”every builtin function in k has an internal id number, and . retrieves them. Entries of the form .(x) are implemented thus; others are commented.

A question: are we supposed to generate the numbers or print them? E.g., for zero, should we return some numeric type containing zero as a value, or should we display the exact string 0? I ask because in there are several default settings that could be useful here, but they all have (32-bit) integer type, which means that in recent (3.x) versions of q/k4, they are displayed on the console with a type suffix of i appended. The following assumes 0i is a valid form of 0, but has alternatives in the comments.

\p     /  0: the default network port (none); alternatively, #(), the count of the empty list
#`     /  1: the count of a null symbol atom; alternatively, if this is considered a character literal, use .(+)
\W     /  2: the default starting day of the week (monday), counting from saturday as 0; alternatively, .(-)
.(*)   /  3
.(%)   /  4
#!`    /  5: the number of namespaces loaded by default (works in 3.2 or 3.3; in earlier versions, use this as 4 and .(&) as 5)
.(|)   /  6
\P     /  7: the default numeric precision (7 significant figures); alternatively, #.j, the count of the .j namespace; alternatively, .(^)
.(=)   /  8
.(<)   /  9
.(>)   / 10
.(var) / 42

TI-BASIC, 41 bytes

0~10:

X
cosh(X
int(e
int(ฯ€
-int(-ฯ€
int(โˆš(ฯ€ยณ
int(ฯ€+ฯ€
int(eยฒ
int(eฯ€
int(ฯ€ยฒ
Xmax

42:

int(ฯ€ยฒ/ecosh(ฯ€

In TI-BASIC, all uninitialized single-letter variables start at 0, and Xmax (the right window boundary of the graph screen) starts at 10.

The mathematical constant ฯ€ is one byte, but e is two bytes.

Darkness, 339 303 bytes

This is where Darkness really shines. Get it? :~)!

Without printing (replaced the space with \s in the first line since it won't show otherwise):

\s

โ–ˆ 

โ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 

With printing:

โ–  

โ–ˆโ–  

โ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–  

Each line must be run individually in this case since the program terminates in the light (a space). However, it is possible to write this on one or several lines in the same program.

Regular darkness (โ–ˆ) increments a register by 1, and the โ–  instruction (some sort of mini-darkness) outputs the contents of the register.

D1ffe7e45e, 112

0
02
020
0202
02020
020202
0202020
02020202
020202020
0202020202
02020202020
202020202020202020202020202020202020202020

Each line is a different snippet.

The numbers in the program don't count as number literals since they're only used as commands.

The final one can definitely be golfed more.

EDIT: I got the interpreter working and all snippets work. If you'd like to test if yourself, add 0f0f to the end of the snippet so the program terminates.

Japt, 34 33 30 bytes

1 byte saved thanks to @ThomasKwa

T
ยฐT
C-A
D-A
E-A
F-A
G-A
ยฐG-A
Iq
ยดA
A
H+A

Here's what each of the different chars means:

T    0
A    10
B    11
C    12
D    13
E    14
F    15
G    16
H    32
I    64
q    sqrt on numbers
ยฐ    ++
ยด    --

O, 36 bytes

l
Nl
CA-
DA-
EA-
FA-
FA-)
A(((
A((
A(
A
A.+.+))

Mostly finding the difference of hex letters,

CA- = 13-11 = 2 DA- = 14-10 = 3

( and ) decrement and increment respectively,

A(( = 10-1-1 = 8

.+ duplicates the top of the stack and adds it together

A.+.+))
10.+.+))
20.+))
40))
42

The first two get the length of the stack (l), which zero, or one when a blank CodeBlock is pushed to the stack (N).

Javascript, 159 chars

No any variables

Any line between ` is a code snippet. The whole code is a test. It returns an array [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 42]. If returning string "42" instead of number 42 is ok, code can be made 3 schars less (remove |[]).

`
+[]
-~[]
!![]+!![]
~~Math.PI
-~Math.PI
-~Math.PI|!![]
Math.PI<<!![]
Math.PI<<!![]|!![]
!![]<<Math.PI
Math.PI*Math.PI^[]
(-~Math.PI|!![])<<!![]
-~Math.PI+[]+(!![]+!![])|[]
`.split('\n').filter(Boolean).map(eval)

Mathematica, 101 bytes

a-a
a/a
โŒŠEโŒ‹
โŒˆEโŒ‰
โŒˆฯ€โŒ‰
โŒŠE+EโŒ‹
โŒˆE+EโŒ‰
โŒŠE*EโŒ‹
โŒˆE*EโŒ‰
โŒˆE*ฯ€โŒ‰
โŒˆฯ€*ฯ€โŒ‰
โŒŠฯ€*ฯ€^ฯ€/EโŒ‹

I'm pretty sure some of these are suboptimal. Those rounding brackets are really expensive.

For consistency, the first two could also be E-E and E/E of course, but I thought it's quite nifty to get 0 and 1 from a computation with undefined variables.

Brainfuck, 70 bytes

+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++
--[>+<++++++]>-

Each line must be run individually.

The first 10 are self explanatory: we increment the value of the cell via each plus.

The 42 is a lot more complex. It relies on the fact the most brainfuck interpreter use 8-bit cells, meaning that all operations on it are done modulo 256. The -- sets cell #0 to 254. Then we enter a loop which runs until cell #0 is 0. Each iteration adds 1 to cell #1 and adds 6 to cell #0. This loops runs 43 times, so cell #1 is 43. Finally, we subtract 1 from cell #1 to make it 42.

I got the most efficient 42 ever found from http://esolangs.org/wiki/Brainfuck_constants

CJam, 27 24 bytes

U    e# 0
X    e# 1
Y    e# 2
Z    e# 3
Z)   e# 3 + 1
YZ+  e# 2 + 3
ZZ+  e# 3 + 3
AZ-  e# 10 - 3
YZ#  e# 2ยณ
A(   e# 10 - 1
A    e# 10
EZ*  e# 14 ร— 3

Thanks to @MartinBรผttner for -1 byte!

Try it online!

MATL, 30 bytes

O
l
H
I
K
Kl+
HI*
KYq
HK*
IH^
K:s
IH^:sI-

H, I, and K are predefined constants for 2, 3, and 4 (like pi). O and l are functions that returns a matrix of zeros (O) or ones (l), the default size is 1x1. : makes a vector, and s sums it, so K:s makes a vector from 1 to 4 and sums it to get 10. Yq is the n-th prime function, so KYq is the 4th prime, 7.

dc, 44

Score does not include newlines between each snippet.

If CJam's U, X, Y, Z, and A constants are allowed, then I assume dc's representation of 10-15 as A-F is also OK.

z
zZ
CI-
DI-
EI-
FI-
II+E-
II+D-
II+C-
II+B-
A
IB+CI-*

@yeti's answer is better.