Skip to main content
3 of 3
Added example of it running.
zgrep
  • 1.6k
  • 8
  • 9

k, 33 bytes

{1+&x=+\{(#$x;4;8)+/~3 5!'x}'1+!x}

Brief (python-ish) explanation:

{                                } / function(x):
                             1+!x  /   array from 1 to x, inclusive
                            '      /   for y in array:
        {                  }       /     function(y):
         (#$x;4;8)                 /       yield [ len(str(y), 4, 8 ][
                  +/~3 5!'x        /         sum([not(y mod 3), not(y mod 5)])
                                   /       ]
      +\                           /   cumulative sum of result of for loop
 1+&x=                             /   get index of x in cumulative sum, add one

Example using kmac 2016.06.28:

 f:{1+&x=+\{(#$x;4;8)+/~3 5!'x}'1+!x}
 ,/f'1 6 15 313 3677
1 3 6 100 1001
zgrep
  • 1.6k
  • 8
  • 9