[Question]
  [
An unspeakable number is a number which is divisible by seven or has seven as one of its digits. A children game is to count skipping unspeakable numbers
```
1 2 3 4 5 6 ( ) 8 9 10 11 12 13 ( ) 15 16 ( ) 18 ...
```
Cantor's version of the game is the sequence defined by recursively filling in the sequence "1 2 3 4 5 6 ( ) 8..." into the gaps ( ) above.
`1 2 3 4 5 6 *1* 8 9 10 11 12 13 *2* 15 16 *3* 18 19 20 *4* 22 23 24 25 26 *5 6* 29 30 31 32 33 34 ***1*** 36 *8* 38 ...` 
Print/output at least the first 7^7 numbers of Cantor's unspeakable number game... 
While the definition is given recursively, you are not obliged to use recursion in the code.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the program with the shortest byte count wins!
Note: The sum of numbers in 1 to 7^7 is 203511962727. The last 10 numbers in that range are 
 823534 823535 221563 108068 823538 823539 823540 823541 823542 221565.
Pastebin dump of first 1000 iterates: <http://pastebin.com/Ksiu9Svf>
  
[Answer]
# Python 2, ~~77~~ ~~75~~ ~~74~~ 70 bytes
*Thanks to @MartinEnder for suggesting the limit of `9e5` which enderd up working after a change.  
Thanks to @mschauer for suggesting an infinite stream, saving 4 bytes.*
```
def f(n=0):
 i=f()
 while 1:n+=1;yield next(i)if'7'in`n`or n%7<1else n
```
This is a generator that yields an infinite stream of the numbers.
[Answer]
# Perl, ~~47~~ ~~46~~ ~~41~~ 39 bytes
Saved 5 bytes thanks to @Dada
```
say$_=$_%7*!/7/?$_:$a[$b++]for@a=1..1e6
```
[Try It Online!](https://tio.run/nexus/perl#@1@cWKkSb6sSr2qupahvrm@vEm@lkhitkqStHZuWX@SQaGuop2eYavb//39dX1M9A0MDAA "Perl – TIO Nexus") TIO Nexus, now with Perl support! This will truncate the output after a certain point, but if you have Perl installed, you can run it locally to produce the full output.
The code makes use of a couple of strange quirks of Perl's syntax, so I'll break down how it works below.
### Code breakdown:
```
say$_=$_%7*!/7/?$_:$a[$b++]for@a=1..1e6
                              @a=1..1e6 #Assign the range (1..1,000,000) to the array @a
                           for          #and then loop through this list, with $_ as an alias for the list member.  As an alias, modifying $_ modifies @a.
      $_%7*!/7/?$_:$a[$b++]             #Ternary operation
      $_%7                              #Returns the residue modulo 7...
          *!/7/                         #...and multiplies it by the negation of whether or not there exists a 7 $_
                                        #Since % and * have the same operator precedence, it must be evaluated in this order
                                        #otherwise we would get (!/7/*$_)%7 instead of ($_%7)*!/7/
               ?$_                      #If the result is non-zero (i.e. truthy), then return $_
                  :$a[$b++]             #Otherwise, return the $b-th element of @a, and increment $b
   $_=                                  #Reassign the result back to $_, modifying @a
say                                     #Prints the result of the assignment, separated by newlines
```
[Answer]
# [Pyth](http://github.com/isaacg1/pyth), ~~25~~ ~~23~~ 22 bytes
*Thanks to @Maltysen for -2 bytes*
```
.V1=+Y
?}7+PbjbT@Y~hZb
```
A program that prints an infinite stream.
[Try it online!](http://pyth.tryitonline.net/#code=LlYxPStZCj99NytQYmpiVEBZfmhaYg&input=) (Output flushed at intervals and times out at 1 min)
**How it works**
```
.V1=+Y
?}7+PbjbT@Y~hZb
Z = 0, Y = []    Implicit variable assignment
.V1              Infinite incrementing for loop with variable b, starting at 1:
   =+Y            Y = Y +
(newline)          (Implicitly print the result of the following:)
?                   If
 }7                  7 is in
    Pb                the prime factorisation of b
   +                  or
      jbT             the digits of b:
         @Y            Index into Y at index
             Z          Z
           ~h          (Increment Z)
                    else:
              b      b
```
[Answer]
## Haskell, ~~67~~ 66 bytes
```
i#x|mod x 7<1||'7'`elem`show x=f!!i:(i+1)#(x+1)|y<-x+1=x:i#y
f=0#1
```
`f` is an infinite list of the numbers.
[Try it online!](https://tio.run/##DcbRCoQgEEDR975iwiBjCZwnIfJXloSUhjSjgp3Af3d9uedu9t5dCKWQ4BzTCgx6xpx73S8uuLjcW/oBG9@2NEn64CAk1@Z3HquGJxJv440SWKKlAwycFx0PdPDY3QGqeuuVTpD6q0dUA/jyBw "Haskell – Try It Online")
`f` starts a new iteration with `1` and an index which number to pick of 0.
Whenever there's a gap we take a new iteration an pick it's `ith` element and continue the current iteration with `i+1`. If there's no gap, we take the current number `x` and go on without increasing `i`.
Edit: -1 byte thanks to @BMO.
[Answer]
# PHP, 80 (Wahooka) 57 54 bytes
While the idea is from Wahooka. I think my version is different enough to make it an own answer:
```
for(;;)echo$a[]=strpos(++$n,55)<-$n%7?"$n ":$a[+$b++];
```
[Answer]
# [MATL](http://github.com/lmendo/MATL), ~~26~~ 25 bytes
```
9e5:`t7\yFYA!7-A*~s:2M(2M
```
[Try it online!](http://matl.tryitonline.net/#code=OWU0OmB0N1x5RllBITctQSp-czoyTSgyTQ&input=) with `9e5` replaced by `9e4`, so that the maximum running time and output size of the online compiler are not exceeded.
### How it works
This uses iteration instead of recursion. (In fact, MATL doesn't have recursion).
An array of numbers from `1` to `9e5` is first generated (this is enough, because `9e5` exceeds `7^7`). Then, numbers that are multiples of `7` or have `7` as digit are identified, and replaced by `1`, `2`, ... The process is iterated until there are no numbers that need to be replaced.
```
9e5:       % Generate array of numbers [1 2 ... 9e5]. This array will become the
           % output, after some numbers have been replaced
`          % Do...while
  t        %   Duplicate the array of numbers
  7\       %   Modulo 7. Gives zero for multiples of 7
  y        %   Duplicate the array of numbers
  FYA!     %   Matrix of decimal digits, with a column for each number
  7-       %   Subtract 7 to each entry of that matrix
  A        %   Array that contains "true" for columns that only contain nonzeros;
           %   that is, for numbers that do not have 7 as digit 
  *        %   Multiply. This corresponds to a logical "and" of the two conditions.
           %   A zero indicates that the number at that index needs to be replaced
  ~        %   Logical negate. Each "true" corresponds to a number to be replaced
  s        %   Sum. This is the amount of numbers to be replaced, say n
  :        %   Push array [1 2 ... n]
  2M       %   Push array of logical values again
  (        %   Replace the numbers at the positions indicated by the logical array
           %   by the values [1 2 ... n]
  2M       %   Push n again. This is used as loop condition, so if it is nonzero
           %   the next iteration will be executed. Note that this executes one
           %   too many iterations: the exit condition is that no replacing has
           %   been needed in the current iteration; but then the current iteration 
           %   (which will be the last) was not really necessary. This does not
           %   matter; the last iteration is useless but also harmless
           % End do...while implicitly. Display implicitly
```
[Answer]
# [Tcl](http://tcl.tk), 121 Bytes
The trivial solution using infinite loop, nothing fancy..
```
set r 0;set n 0;while {[set r [expr $r+1]]} {if {![expr $r%7]||(7 in[split $r ""])} {puts [set n [expr $n+1]]} {puts $r}}
```
Ungolfed:
```
set r 0
set n 0
while {[set r [expr $r+1]]} {
  if {![expr $r % 7] || (7 in [split $r ""])} {
    puts [set n [expr $n+1]]
  } {
    puts $r
  }
}
```
[Answer]
# PHP, ~~106~~ 80 bytes
Thank you Ismael Miguel for help with the ternary solution and shorter loop code using for instead of while.
Could not verify the last parts of the full sequence due to PhpFiddle's 30 second max runtime. Seems to work at least up to 1K based on the sample output provided by the OP.
**Golf:**
```
for($n=1;;$n++)echo$a[]=!(strpos($n,"7")>-1||$n%7==0)?"$n ":array_shift($a)." ";
```
**Original golfed version**:
```
$n=1;while(1){if(!(strpos($n,"7")>-1||$n%7==0)){echo$a[]=$n." ";}else{echo$a[]=array_shift($a)." ";}$n++;}
```
[Answer]
# Julia, 62 bytes
```
x=[];j=0;for i=1:7^7;x=[x;i%7<1||('7' in "$i")?x[j+=1]:i]end;x
```
Nothing fancy. Uses that the sequence within the gaps is the sequence itself. Makes excessive array copies to save some bytes.
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 39 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319)
`{(⍵⍴⍨⍴i)@(i←⍸('7'∊¨⍕¨⍵)∨0=7|⍵)⊢⍵}⍣≡⍳7*7`
`⍳7*7` is 1 2 3...77
`{ }⍣≡` is the *fixed point* operator - apply a function repeatedly until the result stabilises
`A@I⊢B` *amend* operator - replace the elements at indices `I` in `B` with `A`
`0=7|⍵` bitmask for where the argument is divisible by 7
`'7'∊¨⍕¨⍵` bitmask for where the decimal formatting of the argument contains a 7
`∨` or
`⍸` at what indices is either of the above bitmasks true?
`i←` assign to `i`
`⍵⍴⍨⍴i` reshape the argument to the number of elements in `i`
[Answer]
# [Perl 6](https://perl6.org), ~~74 57 54~~ 53 bytes
```
sub u{my@u;(1..*).map: {if $_%%7||.comb('7') {@u||=u;@u.shift} else {$_}}}
```
```
sub u{(1..*).map: {$_%%7||.comb('7')??(@||=u).shift!!$_}}
```
```
sub u{map {$_%%7||.comb('7')??(@||=u).shift!!$_},1..*}
```
```
sub u{map {$_%%7||.comb(~7)??(@||=u).shift!!$_},1..*}
```
[Try it](https://tio.run/nexus/perl6#Ky1OVSgz00u2/l9cmqRQWp2bWKBQrRKvqmpeU6OXnJ@bpFFnrmlvr@FQU2NbqqlXnJGZVqKoqBJfq2Oop6dV@19ZISczN7NEAYhK8hWMTA0MDBRS80qKMlOLufSKEysV0vKLFEo1NKPjwHKx/wE "Perl 6 – TIO Nexus")
## Expanded:
```
sub u{
  map             # for each element transform using:
  { # bare block lambda with implicit parameter ｢$_｣
      $_ %% 7     # if it is divisible by 7
      ||          # or
      .comb(~7)   # contains the number 7 (implicit method call on ｢$_｣)
    ??            # then
      ( @ ||= u ) # store a new instance of the Seq into an unnamed state array if it is empty
                  # ( it is only empty the first time it is seen in this Seq instance )
      .shift      # pull one off of the front
    !!            # else
      $_          # return the value
  },
  1 .. *          # infinite range starting at one ( elements to be mapped over )
}
```
## Test:
```
$ time perl6 -e'sub u{map {$_%%7||.comb(~7)??(@||=u).shift!!$_},1..*};put 203511962727 == sum u()[^7**7]'
True
real    2m45.744s
user    2m45.416s
sys     0m0.212s
```
[Answer]
## Javascript, 80 bytes
```
n=[]
r=l=>(m=n[l]=++n[l]||1,!/7/.test(m)m%7?m:r(l+1))
for(;;)console.log(r(0))
```
Since there is only a minimum requirements but not a maximum requirements, this solution continues to output indefinitely.
To verify that the algorithm is correct, you can execute the same code printing only the last 10 numbers and the sum:
```
n = []
r = l => (m = n[l] = ++n[l] || 1, !/7/.test(m) && m % 7 ? m : r(l + 1))
var tot = 0
for (i = 0; i + 1; i++) {
    v = r(0)
    tot += v
        if (i > Math.pow(7, 7) - 11) {
        console.log(v)
    }
    if (i === Math.pow(7, 7) - 1) {
        console.log(tot)
        break
    }
}
```
[Answer]
# Ceylon, 202 bytes
```
object u satisfies{Integer*}{iterator()=>object satisfies Iterator<Integer>{variable value i=0;late Iterator<Integer>n;next()=>if(++i%7<1||'7'in"``i``")then(i<8then(n=iterator())else n).next()else i;};}
```
This is not a function, but an object declaration implementing an infinite sequence (Iterable). The object can be printed directly, `print(u)` outputs this:
`{ 1, 2, 3, 4, 5, 6, 1, 8, 9, 10, 11, 12, 13, 2, 15, 16, 3, 18, 19, 20, 4, 22, 23, 24, 25, 26, 5, 6, 29, 30, ... }`
To print more, use `printAll(u)`. The following code uses newlines, and also prints the sum (and the first 30 elements shown above):
```
shared void run() {
    printAll(u.take(7^7), "\n");
    print(sum({0, * u.take(7^7)}));
    print(u);
}
```
Here is the ungolfed and commented version:
```
// Prints cantor's unspeakable numbers.
//
// Question:  http://codegolf.stackexchange.com/q/101231/2338
// My answer: http://codegolf.stackexchange.com/a/101297/2338
// this object u (which is like a singleton class with its single instance)
// implements the Iterable<Integer> interface.
object u satisfies {Integer*} {
    // That interface has just one formal method,
    // `shared formal Iterator<Integer> iterator()`.
    // Lets implement it by ...
    iterator()
    // ... providing for each call ...
            =>
                // ... a new (anonymous) object, which
                // implements the Iterator<Integer> interface.
                object satisfies Iterator<Integer> {
                    // This is the counter (the type `Integer`
                    // is longer than `value`, so we infer it).
                    // We start at 0.
                    variable value i = 0;
                    // This is a nested Iterator. It will be
                    // initialized when first needed, so we don't
                    // get an endless recursion when creating the
                    // first iterator.
                    late Iterator<Integer> n;
                    // `shared formal Integer next()` is the single method
                    // of Iterator which needs to be implemented.
                    next()
                    // each time it is called, the following
                    // expression will be evaluated.
                            =>
                                // increment the counter, then check if it
                                // is an unspeakable number.
                                if (++i % 7 < 1 || '7' in "``i``")
                                then
                                    // if so, take the nested iterator (and the
                                    //  first time, for i == 7, create it first),
                                    // and take its next element.
                                    (i < 8 then (n = iterator()) else n).next()
                                else
                                    // otherwise, just return i.
                                    i;
                };
}
```
[Answer]
# Ruby, 80 bytes
`l=->x{x%7==0||x.to_s[/7/]};a=(1..100);b=a.reject &l
p a.map{|x|!l[x]?x:b.shift}`
First submission, I'm sure it can be improved :)
[Answer]
# C ~~157~~ 155 Bytes
```
int c[999999],r;main(_,p){if(_){p=--_;c[_]=1;for(;;){printf("%d ",c[_]);main(0,++_+1);c[_]=r?_+1:c[p++];}}else!p?r=1:p%7?p%10-7?main(0,p/10):(r=0):(r=0);}
```
It looks right, I didn't bother to fully check. Goes up to 999999 which is apparently large enough.
Ungolfed version:
```
int cantor_n[1000000];
int cantor_n_safe(int x) {
    if (!x) return 1;
    if (x % 7 == 0) return 0;
    if (x % 10 == 7) return 0;
    return cantor_n_safe(x / 10);
}
int main(_, prev_index) {
    prev_index = --_;
    cantor_n[_] = 1;
    for(;;) {
        printf("%d ", cantor_n[_]);
        _++;
        if (!cantor_n_safe(_+1)) {
            cantor_n[_] = cantor_n[prev_index++];
        } else {
            cantor_n[_] = _+1;
        }
    }
    return 0;
}
```
Partially golfed version:
```
int c[999999];int r;
safe(x){ 
    !x?
        r=1:
        x%7?
            x%10-7?
                safe(x/10):
                (r=0):
            (r=0);
}
main(_){
    int p;
    p=--_;
    c[_]=1;
    for(;;){
        printf("%d ",c[_]);
        safe(++_+1);
        if (!r) {
            c[_]=c[p++];
        } else {
            c[_]=_+1;
        }
    }
}
```
[Answer]
## R, 86 bytes
```
x=1;while(T<7^7){T=T+1;x[T]=if(!T%%7|7%in%el(strsplit(c(T,""),""))){F=F+1;x[F]}else T}
```
Uses R's Truthy built-in `T` (initialized to `TRUE`/`1`) to count the numbers in the the sequence and the Falsy value `F` (initialized to `FALSE`/`0`) to count the unspeakables. Other than that the program simply checks whether each number is divisible by seven or contains the number.
[Answer]
# C - 115 bytes
```
s[99],r;g(x){return x%10-7&&(!x||g(x/10));};f(i){(r=++s[i])%7&&g(r)||f(i+1);}main(){for(;;f(0),printf("%d\n",r));}
```
EDIT: Thanks to @mschauer who pointed out I missed some things.
[Answer]
# Mathematica, 82 bytes
```
Nest[#2&[i=1,If[Or@@(#==7&)/@IntegerDigits@#,i++,#]&/@#]&,Table[i,{i,7^7}],20]
```
[Answer]
# JavaScript 81 bytes
### Original (98 bytes)
```
for(c=0,i=1;i<=Math.pow(7,7);i++)/7/.test(i)||i%7==0?(6==c?c=1:c++,console.log(c)):console.log(i);
```
### Golfed
```
p=console.log;for(c=0,i=1;i<9e5;i++)/7/.test(i)||i%7==0?(6==c?c=1:c++,p(c)):p(i);
```
[Answer]
## Befunge, 100 or 156 bytes
This first version is the more portable of the two, limiting itself to 7-bit memory cells, which is what you get in the reference interpreter.
```
"O":0>\#09#:p#-:#1_v<0$.< 
9\*"~"g9+1:+1::p00:<+3$_^#g01$$<v"~":/"~"p9g00%"~"::+1+g9\*"~"+g
:#15#+5#g+#0%#17#\-#/!#+\#5:#5_^>%00g1+9p"~"/00g2+9p::7%!10>>p#0
```
The second version only works with interpreters that have 32-bit memory cells, and thus isn't strictly standard Befunge, but that lets us store larger values in memory without having to split them across cells. 
```
"O":0>\#09#:p#-:#1_v<0$.< 
%7::p9g00:+1g9:p00:<+1$_^#g01$$<v01!
:#15#+5#g+#0%#17#\-#/!#+\#5:#5_^>p#0
```
In both cases the program runs indefinitely, but the first version will overflow around the 2 million mark, while the second version should get up to the max int value (around 2 billion).
You can [Try it online](http://befunge.tryitonline.net/#code=Ik8iOjA-XCMwOSM6cCMtOiMxX3Y8MCQuPCAKOVwqIn4iZzkrMTorMTo6cDAwOjwrMyRfXiNnMDEkJDx2In4iOi8ifiJwOWcwMCUifiI6OisxK2c5XCoifiIrZwo6IzE1Iys1I2crIzAlIzE3I1wtIy8hIytcIzU6IzVfXj4lMDBnMSs5cCJ-Ii8wMGcyKzlwOjo3JSExMD4-cCMw&input=), but you'll need to kill the process to prevent it from trying to run forever.
[Answer]
## Clojure, 130 bytes
```
#(let[R(range(inc %))](rest((reduce(fn[[r s]i](if(or(=(mod i 7)0)((set(str i))\7))[(assoc r i(r s))(inc s)][r s]))[(vec R)0]R)0)))
```
Basic reduce, keeping track of contents of the result vector and how many values have been skipped. The last `0` takes first element of the reduced `[r s]`, `rest` drops first element of the 0-indexed result.
[Answer]
## Perl6, 41 bytes
```
put {($_=++$)%%7|m/7/??@_[$++]!!$_}…1e6
```
[Answer]
# JavaScript, 64 bytes
```
for(f=n=>!/7/.test(m=++n[0])*m%7?m:f(n.t=n.t||[0]);;)alert(f(f))
```
```
output=[];index=0;for(f=n=>!/7/.test(m=++n[0])*m%7?m:f(n.t=n.t||[0]);index<100;)output[index++]=f(f);console.log(output.join(','))
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 25 bytes
```
[]L³õ@pX%7«/7/tX ?X:UgV°
```
[Test the sum](https://ethproductions.github.io/japt/?v=2.0a0&code=W11Ms/VAcFglN6svNy90WCA/WDpVZ1awCnMwLDdwNyl4&input=) and [last 10 elements.](https://ethproductions.github.io/japt/?v=2.0a0&code=W11Ms/VAcFglN6svNy90WCA/WDpVZ1awCnM3cDcgLUEsN3A3&input=)
Generates first 1,000,000 entries of the sequence and prints them. One million is the shortest number over `7**7 == 823543` in Japt.
The trailing newline is significant, as it activates the implicit assignment to `U`.
Generating the list only takes around a second, but outputting the entire array will likely make your browser hang.
### Unpacked & How it works
```
[]L³õX{UpX%7&&!/7/tX ?X:UgV++
[]                            Assign empty array to U
  L³õX{                       Map over 1 to 1,000,000 inclusive...
         X%7&&                  If X is not divisible by 7 and
              !/7/tX            X does not have a digit 7
                     ?X:UgV++   then X, otherwise the next element already in U
       Up                       Push it to the end of U
                              Implicit print U
```
Uses the property that the recursive definition can be resolved by looking at the already generated sequence.
[Answer]
# [Tcl](http://tcl.tk/), 72 bytes
```
while 1 {puts [expr {[incr i]%7&&7ni[split $i ""]?$i:([incr s]-1)%6+1}]}
```
[Try it online!](https://tio.run/##K0nO@f@/PCMzJ1XBUKG6oLSkWCE6taKgSKE6OjMvuUghM1bVXE3NPC8zurggJ7NEQSVTQUkp1l4l00oDoqA4VtdQU9VM27A2tvb/fwA "Tcl – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 17 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
[N>ÐÑª˜7åi¯¾è¼}=ˆ
```
Port of [*@TheBikingViking*'s Pyth answer](https://codegolf.stackexchange.com/a/101288/52210), so make sure to upvote him as well!  
Also outputs the infinite sequence, each number on a separated line.
[Try it online.](https://tio.run/##ASUA2v9vc2FiaWX//1tOPsOQw5HCqsucN8OlacKvwr7DqMK8fT3Lhv//)
**Explanation:**
```
[               # Start an infinite loop:
 N>             #  Push the 0-based loop-index + 1
   Ð            #  Triplicate this now 1-based index
    Ñ           #  Pop one and push a list of its divisors
     ª          #  Implicitly convert another number to a list of digits, and
                #  append this list of divisors to it
      ˜         #  Flatten it
       7åi      #  Pop and if it contains a 7
                #  (so either the digits contained a 7 or the divisors):
          ¯     #   Push the global array
           ¾è   #   Index the counter variable into it
             ¼  #   And increase the counter variable by 1 afterwards
         }      #  Close the if-statement
          =     #  Print the top number (without popping)
           ˆ    #  Pop and add it to the global array
```
If we only want to output the first \$7^7\$ results instead of printing indefinitely, the `[N>` could be `7mEN` instead.
]