Skip to main content
saved 1 byte
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

##JavaScript (ES6), 119 118118 117 bytes

f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m&&(>m?b[d]=b[d]/0||d):0),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   and for each value d in a[]:
      c < d &                        //     if c is less than d and
      (d *= c) > m &&?                 //     d = d * c is greater than m:
      (  b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
      :                              //     else:
        0                            //       do nothing
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call
f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m&&(>m?b[d]=b[d]/0||d):0),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

for(var n = 0; n < 10; n++) {
  console.log('MU[' + n + '] = ' + f(n));
}

##JavaScript (ES6), 119 118 bytes

f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   and for each value d in a[]:
      c < d &                        //     if c is less than d and
      (d *= c) > m &&                //     d = d * c is greater than m:
      (b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call
f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

for(var n = 0; n < 10; n++) {
  console.log('MU[' + n + '] = ' + f(n));
}

##JavaScript (ES6), 119 118 117 bytes

f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m?b[d]=b[d]/0||d:0),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   and for each value d in a[]:
      c < d &                        //     if c is less than d and
      (d *= c) > m ?                 //     d = d * c is greater than m:
        b[d] = b[d] / 0 || d         //       b[d] = either d or +Infinity (see 'How?')
      :                              //     else:
        0                            //       do nothing
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call
f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m?b[d]=b[d]/0||d:0),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

for(var n = 0; n < 10; n++) {
  console.log('MU[' + n + '] = ' + f(n));
}
saved 1 byte
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

##JavaScript (ES6), 119119 118 bytes

f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&&d=>c<d&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   and for each value d in a[]:
      c < d &&&                        //     if c is less than d and
      (d *= c) > m &&                //     d = d * c is greater than m:
      (b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call
f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&&d=>c<d&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

for(var n = 0; n < 10; n++) {
  console.log('MU[' + n + '] = ' + f(n));
}

##JavaScript (ES6), 119 bytes

f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   for each value d in a[]:
      c < d &&                       //     if c is less than d and
      (d *= c) > m &&                //     d = d * c is greater than m:
      (b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call
f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

for(var n = 0; n < 10; n++) {
  console.log('MU[' + n + '] = ' + f(n));
}

##JavaScript (ES6), 119 118 bytes

f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   and for each value d in a[]:
      c < d &                        //     if c is less than d and
      (d *= c) > m &&                //     d = d * c is greater than m:
      (b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call
f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m&&(b[d]=b[d]/0||d)),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

for(var n = 0; n < 10; n++) {
  console.log('MU[' + n + '] = ' + f(n));
}
minor update
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650
b[d]               | b[d] / 0  | b[d] / 0 || d
-------------------+-----------+--------------
undefined          | NaN       | d
somealready integerequal to d | +Infinity | +Infinity
+Infinity          | +Infinity | +Infinity
f = (n, a = [2, m = 3]) =>           // given: n = input, aa[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in aa[]:
    a.map(d =>                       //   for each value d in aa[]:
      c < d &&                       //     if c is less than d and
      (d *= c) > m &&                //     d = d * c is greater than m:
      (b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in aa[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use aa[] as the 2nd parameter
  )                                  // end of recursive call
b[d]         | b[d] / 0  | b[d] / 0 || d
-------------+-----------+--------------
undefined    | NaN       | d
some integer | +Infinity | +Infinity
+Infinity    | +Infinity | +Infinity
f = (n, a = [2, m = 3]) =>           // given: n = input, a = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a:
    a.map(d =>                       //   for each value d in a:
      c < d &&                       //     if c is less than d and
      (d *= c) > m &&                //     d = d * c is greater than m:
      (b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a as the 2nd parameter
  )                                  // end of recursive call
b[d]               | b[d] / 0  | b[d] / 0 || d
-------------------+-----------+--------------
undefined          | NaN       | d
already equal to d | +Infinity | +Infinity
+Infinity          | +Infinity | +Infinity
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   for each value d in a[]:
      c < d &&                       //     if c is less than d and
      (d *= c) > m &&                //     d = d * c is greater than m:
      (b[d] = b[d] / 0 || d)         //       b[d] = either d or +Infinity (see 'How?')
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call
improved the 'How?' section
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650
Loading
added the 'How?' section
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650
Loading
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650
Loading