# A Euro-iginal Sequence

Given a positive integer n output the n-th number of the euro-iginal sequence.

## Calculating the Sequence

This sequence is equal to OEIS A242491.

A number is part of said sequence if the number can be made up by using as many different euro coins or notes, but only one of each. Note that you don't have to consider cents.

Example:

6 would be in the sequence, as it can consist of a 1-euro coin and a 5-euro-note.

4 would NOT be in the sequence, as it can't be formed with the given requirements.

To give everyone an overview, heres a list with euro values you have to consider:

1€, 2€, 5€, 10€, 20€, 50€, 100€, 200€, 500€

Note that this sequence only ranges from 0 (yes, 0 is included!) to 888.

Here are the first 15 elements of this sequence:

0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, ...

## Test Cases

Input -> Output

2 -> 1
6 -> 6
21 -> 25
33 -> 50

• What is the largest possible input? Can we have some larger test cases?
– xnor
Oct 5, 2017 at 6:29
• May we index as a(1)=1 like the oeis table?
– xnor
Oct 5, 2017 at 6:48
• Can we assune N<=512? Oct 5, 2017 at 7:09
• @xnor If it still returns 0 for n=0 it's fine. Oct 5, 2017 at 9:44
• Can we output the 0-indexed results instead of 1-indexed? So 0->0; 1->1; 5->6; 20->25; 32->50; 511->888 instead of 1->0; 2->1; 6->6; 21->25; 33->50; 512->888. Oct 5, 2017 at 9:58

# Jelly, 7 bytes

b8d4ḅ5Ḍ


Try it online!

### How it works

b8d4ḅ5Ḍ  Main link. Argument: n (integer)

b8       Convert n from integer to base 8.
d4     Divmod each base-8 digit by 4, mapping the digit d to [d / 4, d % 4].
ḅ5   Convert the quotient-remainder pairs from base 5 to integer, mapping
[d / 4, d % 4] to (d / 4 * 5 + d % 4).
The last two steps establish the following mapping for octal digits.
0 -> [0, 0] -> 0
1 -> [0, 1] -> 1
2 -> [0, 2] -> 2
3 -> [0, 3] -> 3
4 -> [1, 0] -> 5
5 -> [1, 1] -> 6
6 -> [1, 2] -> 7
7 -> [1, 3] -> 8
Ḍ  Convert the resulting array of digits from decimal to integer.


# Python 2, 32 bytes

lambda n:n+n/4+n/32*10+n/256*100


Try it online!

# Python 2, 34 bytes

f=lambda n:n and 10*f(n/8)+n%8*5/4


Try it online!

• I keep looking at your math trying to figure out how you got to your solution. How did you find that solution? Oct 7, 2017 at 3:46

# Husk, 8 7 5 bytes

Σ!Ṗİ€


Try it online! Edit: -3 bytes thanks to Zgarb!

   İ€   build-in infinite sequence [1,2,5,10,20,50,100,...]
Ṗ     power set [[],[1],[2],[1,2],[5],[1,5],[2,5],[1,2,5],...]
!      index into the list with given input, e.g. 4 yields [1,2]
Σ       take the sum of that list


I heard that it is planned to change İ€ to the finite sequence [0.01,0.02,0.05,0.1,0.2,0.5,1,2,5,10,...,500] in the future. Once that is implemented, the following code should work a byte count of 7:

Σ!Ṗ↓6İ€


where ↓6 drops the first six elements of the sequence. Try it online!

• Is it intended that the program adds 2 0s to the output? Oct 5, 2017 at 9:47
• Σ!Ṗ↑9İ€ should save a byte. Oct 5, 2017 at 10:40
• @IanH. The first program produces the correct output. The second TIO link will only work after the implementation of İ€ has been changed. That it is currently returning 2500 instead of 25 is merely a coincidence. Oct 5, 2017 at 16:01
• @Zgarb Thanks a lot! Oct 5, 2017 at 16:06
• I think you can also remove ↑9, since the challenge text doesn't mention what should happen for inputs beyond 512. Oct 5, 2017 at 17:45

# Perl 5, 29 bytes

28 bytes code + 1 for -p.

Uses 0 based indexing.

$_=sprintf"%o",$_;y/4-7/5-8/


Try it online!

• should be sprintf"%o",$_-1, because of sequence indexed from 1 for example 2 -> 1, altough OEIS sequence starts with 1 Oct 6, 2017 at 8:40 • This uses 0 indexing as allowed by the question (or at least, OPs comments under the question). I did have the -1 until OP clarified! Oct 6, 2017 at 8:57 # Jelly, 11 bytes 0Df9,4Ṇ$$#Ṫ  Try it online! Thanks a lot to @Erik the Outgolfer for a lot of help in chat! ## Explanation 0Df9,4Ṇ$$#Ṫ - Monadic link. 0 # - Collect first N matches, starting from 0. D - Digits. f9,4 - Filter-Keep the digits that are either 9 or 4. Yields [] when there are none. Ṇ - Logical NOT. [] -> 1 (truthy), non-empty list -> 0 (falsy). Ṫ - Pop and return the last element.  # Mathematica, 47 bytes (FromDigits/@0~Range~8~Drop~{5}~Tuples~3)[[#]]&  # Mathematica, 48 bytes Sort[Tr/@Subsets@Join[x={1,2,5},10x,100x]][[#]]&  -6 bytes from Martin Ender • Join[x={1,2,5},10x,100x] and Subsets@. Oct 5, 2017 at 8:28 # Java 8, 28 26 bytes 0-indexed: n->n+n/4+n/32*10+n/256*100  Port of @xnor's Python 2 answer (which used to be deleted, hence the original 1-indexed answer below). Try it here. Old 1-indexed answer (28 bytes): n->--n+n/4+n/32*10+n/256*100  Port of @Tfeld's Python 2 answer before he made his last edit. Instead of using ~- a bunch of times, it uses --n to decrease n by 1 right after entering the lambda function. Try it here. # 05AB1E, 7 bytes 0-indexed. Port of Mr. Xcoder's Jelly answer µN7nÃg_  Try it online! Explanation µ # loop over increasing N until input matches are found _ # the logical negation of g # the length of N # N 7nÃ # with only 4s and 9s kept  • Nice, seems like 05AB1E is the best tool for my algorithm :-). Dennis' arithmagic approach would get you 9 (maybe golfable) bytes: 8в4‰ε5β}J (0-indexed) Oct 5, 2017 at 13:25 • @Mr.Xcoder: I had 8в4‰J5öJ for 8 with Dennis' trick. Yours was better suited for 05AB1E indeed :) Oct 5, 2017 at 13:26 # Python 2, 4038 36 bytes Inspired by xnor's answer, but uses 1-indexing. lambda n:~-n*5/4+~-n/32*10+n/257*100  Try it online! # Python 2, 7865626158 56 bytes lambda i,n=0:f(i+~-('4'innor'9'inn),n+1)if i else~-n  Try it online! • 36 bytes Oct 5, 2017 at 8:56 • Is there a reason @xnor deleted his answer, because it seems completely valid to me.. :S Oct 5, 2017 at 10:14 • @KevinCruijssen I've undeleted it now that the asker answered that shifting the indexing to a(1)=1 is allowed. – xnor Oct 5, 2017 at 10:19 # Jelly, 15 bytes 0-indexed. æ»“£¦®‘×“¢½d‘S+  Try it online! ## Explanation This is based off of xnor's Python solution, where the algorithm is n + n/4 + n/32*10 + n/256*100. lambda n: sum(i * j for i, j in zip([n / i for i in [1, 4, 32, 256]], [1, 1, 10, 100]]))  Since the first n is unmodified, this is the same as: lambda n: sum(i * j for i, j in zip([n / i for i in [4, 32, 256]], [1, 10, 100]])) + n  Since 4, 32, and 256 are all powers of two, they can be translated into bit shifts. lambda n: sum(i * j for i, j in zip([n >> i for i in [2, 5, 8]], [1, 10, 100]])) + n  The golfiness doesn't translate well in Python, but turning the lists into Jelly strings of code page indices reduces Jelly's byte count. lambda n: sum(i * j for i, j in zip([n >> i for i in map(jelly_codepage.index, '£¦®')], map(jelly_codepage.index, '¢½d'))) + n  ## Jelly, 24 bytes “¡¿ɼcÞµ³Ṡf2ż’bȷ3ŒPS€Ṣ ị¢  Try it online! • +1 for having € in your code. :) But -1 because this is the first time ever a Jelly answer is longer than my Java answer. XD Shame on you (and gl & hf golfing it further). ;) Oct 5, 2017 at 10:26 • @KevinCruijssen This is going to wreak havoc on the Elo ratings. – xnor Oct 5, 2017 at 10:28 • @KevinCrujissen A bit better now? :P Oct 5, 2017 at 11:15 • @icrieverytim You made a typo in my name, so I didn't get the summon. But yes, a lot better. :) +1 from me. Oct 5, 2017 at 12:28 # Octave, 59 bytes @(n)unique((dec2bin(0:511)-48)*kron([1 2 5],10.^(0:2))')(n)  Try it online! ### Explanation The code creates the full sequence and then indexes into it. First, the binary expressions of the numbers 0, 1, ... 511 are generated as a 512×9 matrix: dec2bin(0:511)-48 (the -48 part is needed because the result of dec2bin is characters, not numbers). This gives 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ... 1 1 1 1 1 1 1 1 1  Then the Kronecker product of [1 2 5] and [1 10 100] is computed kron([1 2 5],10.^(0:2)) and transposed ' which gives the nine possible euro values as a 9×1 vector: 1 2 5 10 20 50 100 200 500  Matrix-multiplying the above matrix and vector * gives a 512×1 vector containing all possible numbers in the sequence, with repetitions and unsorted:  0 500 50 ... 388 888  Deduplicating and sorting unique(...) gives the full sequence:  0 1 2 ... 887 888  Finally, the input is used to index into this sequence (n) to produce the output. # Ruby, 28 27 bytes ->x{("%o"%x).tr"4-7","5-8"}  Try it online! ### Explanation Output octal string, replace digits 4..7 with 5..8 • I think you can remove the space after .tr for -1 Oct 5, 2017 at 22:03 # Bash + GNU utilities, 20 dc -e8o?p|tr 4-7 5-8  Reads a zero-indexed index from STDIN. # 05AB1E, 20 bytes 9LD3%n>s3/óTsm*æO{sè  Try it online! 1-indexed, using the formula of [(n%3)^2 + 1]*10^floor(n/3) to generate the first 10 terms, then using powerset to calculate all possible combinations... Then I sort it and pull a[b]. See it in action below: Full program: 9LD3%n>s3/óTsm*æO{sè current >> 9 || stack: [] current >> L || stack: ['9'] current >> D || stack: [[1, 2, 3, 4, 5, 6, 7, 8, 9]] current >> 3 || stack: [[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9]] current >> % || stack: [[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], '3'] current >> n || stack: [[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 0, 1, 2, 0, 1, 2, 0]] current >> > || stack: [[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 4, 0, 1, 4, 0, 1, 4, 0]] current >> s || stack: [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 5, 1, 2, 5, 1, 2, 5, 1]] current >> 3 || stack: [[2, 5, 1, 2, 5, 1, 2, 5, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]] current >> / || stack: [[2, 5, 1, 2, 5, 1, 2, 5, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], '3'] current >> ó || stack: [[2, 5, 1, 2, 5, 1, 2, 5, 1], [0.3333333333333333, 0.6666666666666666, 1.0, 1.3333333333333333, 1.6666666666666667, 2.0, 2.3333333333333335, 2.6666666666666665, 3.0]] current >> T || stack: [[2, 5, 1, 2, 5, 1, 2, 5, 1], [0, 0, 0, 1, 1, 1, 2, 2, 2]] current >> s || stack: [[2, 5, 1, 2, 5, 1, 2, 5, 1], [0, 0, 0, 1, 1, 1, 2, 2, 2], 10] current >> m || stack: [[2, 5, 1, 2, 5, 1, 2, 5, 1], 10, [0, 0, 0, 1, 1, 1, 2, 2, 2]] current >> * || stack: [[2, 5, 1, 2, 5, 1, 2, 5, 1], [1, 1, 1, 10, 10, 10, 100, 100, 100]] current >> æ || stack: [[2, 5, 1, 20, 50, 10, 200, 500, 100]] current >> O || stack: < OMITTED, THE RESULT OF POWERSET IS HUGE > current >> { || stack: [[0, 2, 5, 1, 20, 50, 10, 200, 500, 100, 7, 3, 22, 52, 12, 202, 502, 102, 6, 25, 55, 15, 205, 505, 105, 21, 51, 11, 201, 501, 101, 70, 30, 220, 520, 120, 60, 250, 550, 150, 210, 510, 110, 700, 300, 600, 8, 27, 57, 17, 207, 507, 107, 23, 53, 13, 203, 503, 103, 72, 32, 222, 522, 122, 62, 252, 552, 152, 212, 512, 112, 702, 302, 602, 26, 56, 16, 206, 506, 106, 75, 35, 225, 525, 125, 65, 255, 555, 155, 215, 515, 115, 705, 305, 605, 71, 31, 221, 521, 121, 61, 251, 551, 151, 211, 511, 111, 701, 301, 601, 80, 270, 570, 170, 230, 530, 130, 720, 320, 620, 260, 560, 160, 750, 350, 650, 710, 310, 610, 800, 28, 58, 18, 208, 508, 108, 77, 37, 227, 527, 127, 67, 257, 557, 157, 217, 517, 117, 707, 307, 607, 73, 33, 223, 523, 123, 63, 253, 553, 153, 213, 513, 113, 703, 303, 603, 82, 272, 572, 172, 232, 532, 132, 722, 322, 622, 262, 562, 162, 752, 352, 652, 712, 312, 612, 802, 76, 36, 226, 526, 126, 66, 256, 556, 156, 216, 516, 116, 706, 306, 606, 85, 275, 575, 175, 235, 535, 135, 725, 325, 625, 265, 565, 165, 755, 355, 655, 715, 315, 615, 805, 81, 271, 571, 171, 231, 531, 131, 721, 321, 621, 261, 561, 161, 751, 351, 651, 711, 311, 611, 801, 280, 580, 180, 770, 370, 670, 730, 330, 630, 820, 760, 360, 660, 850, 810, 78, 38, 228, 528, 128, 68, 258, 558, 158, 218, 518, 118, 708, 308, 608, 87, 277, 577, 177, 237, 537, 137, 727, 327, 627, 267, 567, 167, 757, 357, 657, 717, 317, 617, 807, 83, 273, 573, 173, 233, 533, 133, 723, 323, 623, 263, 563, 163, 753, 353, 653, 713, 313, 613, 803, 282, 582, 182, 772, 372, 672, 732, 332, 632, 822, 762, 362, 662, 852, 812, 86, 276, 576, 176, 236, 536, 136, 726, 326, 626, 266, 566, 166, 756, 356, 656, 716, 316, 616, 806, 285, 585, 185, 775, 375, 675, 735, 335, 635, 825, 765, 365, 665, 855, 815, 281, 581, 181, 771, 371, 671, 731, 331, 631, 821, 761, 361, 661, 851, 811, 780, 380, 680, 870, 830, 860, 88, 278, 578, 178, 238, 538, 138, 728, 328, 628, 268, 568, 168, 758, 358, 658, 718, 318, 618, 808, 287, 587, 187, 777, 377, 677, 737, 337, 637, 827, 767, 367, 667, 857, 817, 283, 583, 183, 773, 373, 673, 733, 333, 633, 823, 763, 363, 663, 853, 813, 782, 382, 682, 872, 832, 862, 286, 586, 186, 776, 376, 676, 736, 336, 636, 826, 766, 366, 666, 856, 816, 785, 385, 685, 875, 835, 865, 781, 381, 681, 871, 831, 861, 880, 288, 588, 188, 778, 378, 678, 738, 338, 638, 828, 768, 368, 668, 858, 818, 787, 387, 687, 877, 837, 867, 783, 383, 683, 873, 833, 863, 882, 786, 386, 686, 876, 836, 866, 885, 881, 788, 388, 688, 878, 838, 868, 887, 883, 886, 888]] current >> s || stack: [[0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 33, 35, 36, 37, 38, 50, 51, 52, 53, 55, 56, 57, 58, 60, 61, 62, 63, 65, 66, 67, 68, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 82, 83, 85, 86, 87, 88, 100, 101, 102, 103, 105, 106, 107, 108, 110, 111, 112, 113, 115, 116, 117, 118, 120, 121, 122, 123, 125, 126, 127, 128, 130, 131, 132, 133, 135, 136, 137, 138, 150, 151, 152, 153, 155, 156, 157, 158, 160, 161, 162, 163, 165, 166, 167, 168, 170, 171, 172, 173, 175, 176, 177, 178, 180, 181, 182, 183, 185, 186, 187, 188, 200, 201, 202, 203, 205, 206, 207, 208, 210, 211, 212, 213, 215, 216, 217, 218, 220, 221, 222, 223, 225, 226, 227, 228, 230, 231, 232, 233, 235, 236, 237, 238, 250, 251, 252, 253, 255, 256, 257, 258, 260, 261, 262, 263, 265, 266, 267, 268, 270, 271, 272, 273, 275, 276, 277, 278, 280, 281, 282, 283, 285, 286, 287, 288, 300, 301, 302, 303, 305, 306, 307, 308, 310, 311, 312, 313, 315, 316, 317, 318, 320, 321, 322, 323, 325, 326, 327, 328, 330, 331, 332, 333, 335, 336, 337, 338, 350, 351, 352, 353, 355, 356, 357, 358, 360, 361, 362, 363, 365, 366, 367, 368, 370, 371, 372, 373, 375, 376, 377, 378, 380, 381, 382, 383, 385, 386, 387, 388, 500, 501, 502, 503, 505, 506, 507, 508, 510, 511, 512, 513, 515, 516, 517, 518, 520, 521, 522, 523, 525, 526, 527, 528, 530, 531, 532, 533, 535, 536, 537, 538, 550, 551, 552, 553, 555, 556, 557, 558, 560, 561, 562, 563, 565, 566, 567, 568, 570, 571, 572, 573, 575, 576, 577, 578, 580, 581, 582, 583, 585, 586, 587, 588, 600, 601, 602, 603, 605, 606, 607, 608, 610, 611, 612, 613, 615, 616, 617, 618, 620, 621, 622, 623, 625, 626, 627, 628, 630, 631, 632, 633, 635, 636, 637, 638, 650, 651, 652, 653, 655, 656, 657, 658, 660, 661, 662, 663, 665, 666, 667, 668, 670, 671, 672, 673, 675, 676, 677, 678, 680, 681, 682, 683, 685, 686, 687, 688, 700, 701, 702, 703, 705, 706, 707, 708, 710, 711, 712, 713, 715, 716, 717, 718, 720, 721, 722, 723, 725, 726, 727, 728, 730, 731, 732, 733, 735, 736, 737, 738, 750, 751, 752, 753, 755, 756, 757, 758, 760, 761, 762, 763, 765, 766, 767, 768, 770, 771, 772, 773, 775, 776, 777, 778, 780, 781, 782, 783, 785, 786, 787, 788, 800, 801, 802, 803, 805, 806, 807, 808, 810, 811, 812, 813, 815, 816, 817, 818, 820, 821, 822, 823, 825, 826, 827, 828, 830, 831, 832, 833, 835, 836, 837, 838, 850, 851, 852, 853, 855, 856, 857, 858, 860, 861, 862, 863, 865, 866, 867, 868, 870, 871, 872, 873, 875, 876, 877, 878, 880, 881, 882, 883, 885, 886, 887, 888]] current >> è || stack: [[0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 33, 35, 36, 37, 38, 50, 51, 52, 53, 55, 56, 57, 58, 60, 61, 62, 63, 65, 66, 67, 68, 70, 71, 72, 73, 75, 76, 77, 78, 80, 81, 82, 83, 85, 86, 87, 88, 100, 101, 102, 103, 105, 106, 107, 108, 110, 111, 112, 113, 115, 116, 117, 118, 120, 121, 122, 123, 125, 126, 127, 128, 130, 131, 132, 133, 135, 136, 137, 138, 150, 151, 152, 153, 155, 156, 157, 158, 160, 161, 162, 163, 165, 166, 167, 168, 170, 171, 172, 173, 175, 176, 177, 178, 180, 181, 182, 183, 185, 186, 187, 188, 200, 201, 202, 203, 205, 206, 207, 208, 210, 211, 212, 213, 215, 216, 217, 218, 220, 221, 222, 223, 225, 226, 227, 228, 230, 231, 232, 233, 235, 236, 237, 238, 250, 251, 252, 253, 255, 256, 257, 258, 260, 261, 262, 263, 265, 266, 267, 268, 270, 271, 272, 273, 275, 276, 277, 278, 280, 281, 282, 283, 285, 286, 287, 288, 300, 301, 302, 303, 305, 306, 307, 308, 310, 311, 312, 313, 315, 316, 317, 318, 320, 321, 322, 323, 325, 326, 327, 328, 330, 331, 332, 333, 335, 336, 337, 338, 350, 351, 352, 353, 355, 356, 357, 358, 360, 361, 362, 363, 365, 366, 367, 368, 370, 371, 372, 373, 375, 376, 377, 378, 380, 381, 382, 383, 385, 386, 387, 388, 500, 501, 502, 503, 505, 506, 507, 508, 510, 511, 512, 513, 515, 516, 517, 518, 520, 521, 522, 523, 525, 526, 527, 528, 530, 531, 532, 533, 535, 536, 537, 538, 550, 551, 552, 553, 555, 556, 557, 558, 560, 561, 562, 563, 565, 566, 567, 568, 570, 571, 572, 573, 575, 576, 577, 578, 580, 581, 582, 583, 585, 586, 587, 588, 600, 601, 602, 603, 605, 606, 607, 608, 610, 611, 612, 613, 615, 616, 617, 618, 620, 621, 622, 623, 625, 626, 627, 628, 630, 631, 632, 633, 635, 636, 637, 638, 650, 651, 652, 653, 655, 656, 657, 658, 660, 661, 662, 663, 665, 666, 667, 668, 670, 671, 672, 673, 675, 676, 677, 678, 680, 681, 682, 683, 685, 686, 687, 688, 700, 701, 702, 703, 705, 706, 707, 708, 710, 711, 712, 713, 715, 716, 717, 718, 720, 721, 722, 723, 725, 726, 727, 728, 730, 731, 732, 733, 735, 736, 737, 738, 750, 751, 752, 753, 755, 756, 757, 758, 760, 761, 762, 763, 765, 766, 767, 768, 770, 771, 772, 773, 775, 776, 777, 778, 780, 781, 782, 783, 785, 786, 787, 788, 800, 801, 802, 803, 805, 806, 807, 808, 810, 811, 812, 813, 815, 816, 817, 818, 820, 821, 822, 823, 825, 826, 827, 828, 830, 831, 832, 833, 835, 836, 837, 838, 850, 851, 852, 853, 855, 856, 857, 858, 860, 861, 862, 863, 865, 866, 867, 868, 870, 871, 872, 873, 875, 876, 877, 878, 880, 881, 882, 883, 885, 886, 887, 888], '32'] 50 stack > [50]  ## JavaScript (ES6), 34 bytes n=>--n+(n>>2)+(n>>5)*10+(n>>8)*100  Or 32 bytes using the correct 0-indexing: f= n=>n+(n>>2)+(n>>5)*10+(n>>8)*100 <input type=number min=0 max=511 value=0 oninput=o.textContent=f(+this.value)><pre id=o>0 • Shouldn't n=1 give 0? Oct 5, 2017 at 7:54 # Jelly, 20 bytes 53b6×þ“¢½d‘FŒPS€Ṣị@‘  Try it online! I know this is longer than the existing answer but I think this approach is golfable from here :P -2 bytes thanks to Erik the Outgolfer • 1,10,ȷ2 -> “¢½d‘ Oct 5, 2017 at 12:20 • @EriktheOutgolfer Oh thanks! Oct 5, 2017 at 12:21 # Retina, 42 bytes .+$*1;
+(1+)\1{7}
$1; 1111 1$&
(1*);
$.1  Try it online! Link includes test cases. 0-indexed. Explanation: .+$*1;


Convert from decimal to unary, with a ; suffix.

+(1+)\1{7}
$1;  Convert to octal, but still using unary representation of the digits with ; after each unary value. 1111 1$&


Add 1 to the values 4-7.

(1*);
\$.1


Convert each value plus its suffix to decimal.

# Pyth, 12 bytes

Uses Dennis' witchcraft.

jkiR5.DR4jQ8


Try it here.

# Pyth,  16 15  13 bytes

e.f!@,9 4jZTt


Verify all the test cases.

Thanks to Erik the Outgofer for some ideas.

# C, 67 bytes

main(n){scanf("%d",&n);printf("%d",n+(n>>2)+(n>>5)*10+(n>>8)*100);}


A direct port from Neil's JavaScript answer, but I thought this should be added for completeness.

Tested on GCC version 6.3.0. It will throw some warnings, but compile anyway.