Minimal Power Root

24

The minimal power iteration of a number \$n\$ is defined as follows:

$$\text{MPI}(n):=n^{\text{min}(\text{digits}(n))}$$

That is, \$n\$ raised to the lowest digit in \$n\$. For example, \$\text{MPI}(32)=32^2=1024\$ and \$\text{MPI}(1234)=1234^1=1234\$.

The minimal power root of a number \$n\$ is defined as the number obtained from repeatedly applying \$\text{MPI}\$ until a fixed point is found. Here is a table of the minimal power roots of numbers between 1 and 25:

   n              MPR(n)
--------------------------
   1                   1
   2                   1
   3              531441
   4                   1
   5                3125
   6 4738381338321616896
   7                   1
   8            16777216
   9                   1
  10                   1
  11                  11
  12                  12
  13                  13
  14                  14
  15                  15
  16                  16
  17                  17
  18                  18
  19                  19
  20                   1
  21                  21
  22                   1
  23              279841
  24                   1
  25                   1

Challenge: Generate the numbers whose minimal power root is not equal to 1 or itself.

Here are the first 50 numbers in this sequence:

3, 5, 6, 8, 23, 26, 27, 29, 35, 36, 39, 42, 47, 53, 59, 64, 72, 76, 78, 82, 83, 84, 92, 222, 223, 227, 228, 229, 233, 237, 239, 254, 263, 267, 268, 269, 273, 276, 277, 278, 279, 285, 286, 287, 289, 296, 335, 338, 339, 342

Rules

  • You may generate the first n numbers of this sequence (0- or 1-indexed), generate the nth term, create a generator which calculates these terms, output infinitely many of them, etc.
  • You may take input and give output in any base, but the calculations for MPR must be in base 10. E.g., you may take input ### (in unary) and output ### ##### ###### (in unary)
  • You must yield numbers. You may not (e.g.) output "3", "5", "6", since those are strings. 3, 5, 6 and 3 5 6 are both valid, however. Outputting 2 3, "23", or twenty-three are all considered invalid representations of the number 23. (Again, you may use any base to represent these numbers.)
  • This is a , so the shortest code (in bytes) wins.

Conor O'Brien

Posted 2018-10-14T20:20:55.233

Reputation: 36 228

2Just curious, how could you prove that a fixed point is found eventually for all n? – nwellnhof – 2018-10-14T22:23:06.777

1@nwellnhof (Rough proof.) Suppose there is no fixed point of $x$, i.e., $\text{MPR}(x)$ doesn't exist. Let $x_i$ be the $i$-th iteration of the $\text{MPI}$ function over $x$. This sequence is strictly increasing, since $a^b>a^{b^c}$ for all $a,b,c\ge2$. Being strictly increasing, the probability of no digit in $x_i$ being 0 or 1 tends towards 0 as $x_i$ tends towards $\infty$. – Conor O'Brien – 2018-10-14T22:39:11.860

Huh. The oeis doesn't have this sequence. – Draco18s no longer trusts SE – 2018-10-15T00:09:19.183

1@ConorO'Brien That shows your hypothesis is plausible, but it doesn't prove it. – kasperd – 2018-10-15T15:37:15.193

1@kasperd Thus the "rough proof" before it. – Conor O'Brien – 2018-10-15T20:13:28.500

I don't understand this challenge. What is the actual goal that determines the result? It's the minimum power of n that fulfils... what condition? – Fabian Röling – 2018-10-16T08:37:48.193

@FabianRöling The challenge is to find what n eventually results in after applying $\text{MPI}$. E.g., for 23, you perform MPI, giving MPI(23) = 23^min(digits(23)) = 23^min(2, 3) = 23^2 = 529. This is the first iteration. Again, MPI(529) = 529^min(5, 2, 9) = 529^2 = 279841. This is the second iteration. Once more, MPI(279841) = 279841^min(2,7,9,8,4,1) = 279841^1 = 279841. Here, MPI(279841) = 279841, and we cannot go any further without repeating the results. Thus, MPR(23) = 279841. We are looking for numbers n such that MPR(n) != 1 && MPR(n) != n. – Conor O'Brien – 2018-10-16T15:26:56.800

Oh, you take the lowest digit as the power, got it. And if it's 0? Then you get to number^0=1, 1^1=1, fixed point or what? – Fabian Röling – 2018-10-16T17:18:17.210

@FabianRöling yes – Conor O'Brien – 2018-10-16T19:34:20.920

Is it OK if we omit numbers whose MPRs do not fit inside the range of numbers supported in our language? For example, the MPR of 335 is outside of the bounds of the largest integer type in my language. – S.S. Anne – 2020-02-04T12:32:28.790

Answers

5

05AB1E, 8 bytes

Generates the nth number 1-indexed

µNÐΔWm}‹

Try it online!

Explanation

µ          # run until counter equals input
 NÐ        # push 3 copies of the current iteration index (1-based)
   Δ  }    # run this code until the result no longer changes     
    Wm     # raise the number to the power of its minimum digit
       ‹   # check if greater than the index

Optionally as an infinite list at the same byte count:

∞ʒDΔWm}‹

Try it online!

Emigna

Posted 2018-10-14T20:20:55.233

Reputation: 50 798

Wait, is that all?.. That looks so much simpeler than I thought it would be.. >.> I'll delete my answer, since it's more than twice as long.. – Kevin Cruijssen – 2018-10-15T12:48:04.050

@KevinCruijssen: I am a bit surprised myself. Thought it would take 12 or so bytes when looking at the task. – Emigna – 2018-10-15T13:44:22.850

2I twiddled with µ and Δ right after the challenge was posted and got this exact same answer, but I was wondering why it didn't work... I used D rather than Ð because I thought one copy would have been used by the fixed-point function and the other by the smaller-than function, but I didn't take into account that I needed yet another copy. Thanks, Emigna, for solving my Enimga. – Mr. Xcoder – 2018-10-15T17:13:21.860

7

Perl 6, 49 bytes

{grep {($_,{$_**.comb.min}...*==*).tail>$_},1..*}

Try it online!

Returns an infinite sequence. I suppose that the following 45 byte version works, too, but I can't prove that the fixed point is always found after n iterations.

{grep {($_,{$_**.comb.min}...*)[$_]>$_},3..*}

nwellnhof

Posted 2018-10-14T20:20:55.233

Reputation: 10 037

5

J, 41 39 37 bytes

(>:[echo^:(<(^0".@{/:~@":)^:_))^:_]1x

Try it online!

This one is a full program printing the infinite sequence. A very rare occasion where a full program beats a verb in J.

How it works

(>:[echo^:(<mpi_fix))^:_]1x    Using the mpi_fix below; it finds the MPI fixpoint
          (<mpi_fix)           Is mpi_fix greater than the input?
    echo^:                     If so, apply echo; do nothing otherwise
                               echo returns an empty array
 >:[                           Discard the above and return input+1
(                   )^:_       Repeat the above infinitely (increment has no fixpoint)
                        ]1x    starting from arbitrary-precision number 1

J, 41 39 bytes

>:^:(>:(^0".@{/:~@":)^:_)^:_@>:@]^:[&0x

Try it online!

A monadic verb. Given a 1-based index, returns the number at that index. The footer checks that first 20 terms are correct.

Reading the word "fixpoint", I immediately thought "Oh yeah, ^:_ will do the great job." Then I ended up with this abomination of angry and sad faces. And it's not even a train, it's a single verb.

Ungolfed & How it works

nth_term =: >:^:(>:(^0".@{/:~@":)^:_)^:_@>:@]^:[&0x

mpi =: ^0".@{/:~@":    Find the MPI
             /:~@":    Sort the string representation
        0   {          Take first item
         ".@           Convert back to number
       ^               Raise the input to the power of above

mpi_fix =: mpi^:_      Find the MPI fixpoint

next_term =: >:^:(>:mpi_fix)^:_@>:    Given a number, find the next term
                               @>:    Increment once, and then...
                  >:mpi_fix           Is mpi_fix not greater than input?
             >:^:           ^:_       Increment while the above is true

nth_term =: next_term@]^:[&0x    Given one-based index, find the nth term
            next_term@]          Apply next_term monadically
                       ^:[       n times
                          &0x    to the starting value of zero

The arbitrary-precision integer 0x is needed to compute the fixpoint accurately, e.g. of the number 6.

Bubbler

Posted 2018-10-14T20:20:55.233

Reputation: 16 616

Great! That's a lot of ^:, my head starts to ache on the second of them :) – Galen Ivanov – 2018-10-15T07:56:29.503

(>:[(<(^{.@/:~&.":)^:_)echo])^:_]1x – FrownyFrog – 2018-11-02T10:35:33.303

33 bytes: _&(_&(]]+]>:(^{.@/:~&.":)^:_)>:)* taking input as an extended integer – miles – 2019-08-08T16:47:51.833

4

Mathematica, 59 51 bytes

-8 bytes thanks to Misha Lavrov.

Select[Range@#,#<(#//.x_:>x^Min@IntegerDigits@x)&]&

Pure function. Takes a number as input, and returns the list of terms up to that number as output. Nothing very complicated here.

LegionMammal978

Posted 2018-10-14T20:20:55.233

Reputation: 15 731

FixedPoint is usually not as good as //. (short for ReplaceRepeated) in code golf. Here, we may save a few bytes with Select[Range@#,1<(#//.x_:>x^Min@IntegerDigits@x)!=#&]&. – Misha Lavrov – 2018-10-15T01:34:33.030

Also, if MPI(x) is neither 1 nor x, then it is always bigger than x, so an even shorter solution is Select[Range@#,#<(#//.x_:>x^Min@IntegerDigits@x)&]&. – Misha Lavrov – 2018-10-15T01:37:06.047

4

Jelly, 10 bytes

*DṂƊƬḊCȦµ#

A monadic Link taking an integer, I, from STDIN which yields the first I entries.

Try it online!

(*DṂƊƬṪ%@µ# works for 10 too)

How?

Counts up starting a n=0 until input truthy results of a monadic function are encountered and yields those ns.

The function repeatedly applies another monadic function starting with x=n and collects the values of x until the results are no longer unique. (e.g.: 19 yields [19]; 23 yields [23,529,279841]; 24 yields [24, 576, 63403380965376, 1]; etc...) and then dequeues the result (removes the leftmost value), complements all the values (1-x) and uses Ȧ to yield 0 when there is a zero in the list or if it's empty.

The innermost function raises the current x to all the digits of x and then keeps the minimum (doing this is a byte save over finding the minimum digit first).

*DṂƊƬḊCȦµ# - Link (call the input number I)
         # - count up from 0 and yield the first I for which this yields a truthy value:
        µ  -   a monadic chain:
    Ƭ      -     collect until results are not unique:
   Ɗ       -       last three links as a monad:
 D         -         convert to a list of decimal digits
*          -         exponentiate
  Ṃ        -         minimum
     Ḋ     -     dequeue
      C    -     compliment
       Ȧ   -     any-and-all?

Jonathan Allan

Posted 2018-10-14T20:20:55.233

Reputation: 67 804

Clever usage of ƬḊCȦ over there. :-) – Erik the Outgolfer – 2018-10-14T21:22:47.943

Ṫ> picks up 0 :( – Jonathan Allan – 2018-10-14T21:28:35.840

4

Pyth, 10 bytes

.f>u^GshS`

Try it online!

This generates a list of the first \$ n \$ such numbers. The auto-filled program has GZZQ as a suffix. This simply finds (.f) the first Q numbers that have a minimal power root u^GshS`G greater than itself Z.

The minimal power root code works by finding a fixed point u of raising the current number G to the power of it's minimal digit, which is the same as the first digit (h) sorted lexicographically (S), then converted back to an integer (s).

FryAmTheEggman

Posted 2018-10-14T20:20:55.233

Reputation: 16 206

3

Python 3, 90 88 bytes

-2 bytes by @mypetlion

def F(x):m=x**int(min(str(x)));return[int,F][m>x](m)
x=1
while 1:x<F(x)and print(x);x+=1

Try it online!

print as an expression saves two bytes over using if statement in Python 2. F computes the MPI fixpoint; the rest gives the infinite sequence to STDOUT.

Bubbler

Posted 2018-10-14T20:20:55.233

Reputation: 16 616

Change return m>x and F(m)or m to return[int,F][m>x](m) to save 2 bytes. – mypetlion – 2018-10-15T18:35:35.810

78 bytes – Lynn – 2018-10-17T11:29:49.860

3

Haskell, 67 62 bytes

filter((<)<*>until((==)=<<g)g)[1..]
g a=a^read[minimum$show a]

Returns an infinite list.

Try it online!

nimi

Posted 2018-10-14T20:20:55.233

Reputation: 34 639

2

Ruby, 52 bytes

x=1;loop{b=x+=1;1while b<b**=b.digits.min;b>x&&p(x)}

Try it online!

Prints infinite sequence

G B

Posted 2018-10-14T20:20:55.233

Reputation: 11 099

51 bytes (uses $. instead of x, saves initialization) – Conor O'Brien – 2018-10-16T18:57:50.167

2

Java 10, 178 173 bytes

v->{for(int x=1,m;;){var b=new java.math.BigInteger(++x+"");for(m=9;m>1;)b=b.pow(m=(b+"").chars().min().orElse(0)-48);if(b.compareTo(b.valueOf(x))>0)System.out.println(x);}}

Port of @GB's Ruby answer, so also prints indefinitely.

Try it online.

Explanation:

v->{             // Method with empty unused parameter and no return-type
  for(int x=1,   //  Start an integer `x` at 1
      m;         //  Temp integer for the smallest digit, starting uninitialized
      ;){        //  Loop indefinitely
    var b=new java.math.BigInteger(++x 
                 //   Increase `x` by 1 first
          +"");  //   And create a BigInteger `b` for the new `x`
    for(m=9;     //   Reset `m` to 9
        m>1;)    //   Loop as long as the smallest digit is not 0 nor 1
      b=b.pow(m=(b+"").chars().min().orElse(0)-48
                 //    Set `m` to the smallest digit in `b`
              ); //    Set `b` to `b` to the power of digit `m`
    if(b.compareTo(b.valueOf(x))>0)
                 //   If `b` is larger than `x`:
      System.out.println(x);}}
                 //    Print `x` with a trailing newline

Kevin Cruijssen

Posted 2018-10-14T20:20:55.233

Reputation: 67 575

1

JavaScript (Node.js), 98 90 89 86 bytes

-3 bytes thanks @Conor O'Brien

function*(){for(n=0n;;x>n&&(yield n))for(x=++n;(b=Math.min(...""+x))-1;)x**=BigInt(b)}

Try it online!

Using the fact that \$MPR(n)>n\$ if \$MPR(n)\notin \{1,n\}\$

Seems that a generator is shorter than returning an array of n numbers?

Or printing infinitely - 72 bytes

for(n=0n;;x>n&&alert(n))for(x=++n;(b=Math.min(...""+x))-1;)x**=BigInt(b)

Try it online!

Shieru Asakoto

Posted 2018-10-14T20:20:55.233

Reputation: 4 445

86 bytes by moving some of the control flow around, eliminating braces. (mainly: if(x>n)yield n to x>n&&(yield n) as an expression) – Conor O'Brien – 2018-10-15T20:18:14.847

1

JavaScript (Node.js), 75 bytes

Returns the \$n\$th term, 1-indexed.

f=(i,x=n=1n)=>(N=x**BigInt(Math.min(...x+'')))>x?f(i,N):(i-=N>n)?f(i,++n):n

Try it online!

Arnauld

Posted 2018-10-14T20:20:55.233

Reputation: 111 334

1

C (gcc), 171 153 138 bytes

__int128 m,a,t,h,s;r(){for(a=10,h=s;a=fmin(h%10,a),h/=10;);a=pow(s,a);a-s&&r(s=a);}f(n){for(;t-n;a-1&&a-m&&printf("%lu ",m,t++))r(s=++m);}

Outputs the first n terms whose MPRs are representable within the largest "integer" type.

Brute-forces the solution but still works surprisingly fast.

Some things may be able to be inlined (such as r, which is only called once), but it may require a decent amount of effort.

See previous revision for solution without -lm.

-18 bytes thanks to ceilingcat!

-15 bytes and ultra-precision thanks to rtpax!

Try it online!

S.S. Anne

Posted 2018-10-14T20:20:55.233

Reputation: 1 161

0

Jelly, 14 bytes

3*DṂ$$ÐLḟ1,$Ɗ#

Try it online!

Erik the Outgolfer

Posted 2018-10-14T20:20:55.233

Reputation: 38 134

0

JavaScript (Chrome), 78 77 bytes

F=x=>(m=x**BigInt(Math.min(...''+x)))>x?F(m):m
for(x=0n;++x;)x<F(x)&&alert(x)

Try it online!

Port of my own Python 3 solution. The latest version of Chrome supports BigInt (tested on my PC). Don't try this code as-is on your browser though.

Bubbler

Posted 2018-10-14T20:20:55.233

Reputation: 16 616

lol was about to golf my answer but you got the lead. 77 bytes Also 77 bytes, my planned golf

– Shieru Asakoto – 2018-10-15T07:40:17.890

0

Racket, 270, 257 233 bytes

(define(f n)(local((define(m x)(expt x(-(first(sort(map char->integer(string->list(~v x)))<))48)))(define(g y)(if(= y(m y))y(g(m y))))(define(k x l)(if(=(length l)n)l(if(< x(g x))(k(+ x 1)(cons x l))(k(+ x 1)l)))))(reverse(k 1'()))))

Try it online!

This is my first Racket submission, so it can definitely be golfed much further. Nevertheless I'm somewhat content, at least for managing to solve the task.

More readable:

(define (f n)
  (local ((define (m x)
           (expt x
                 (- (first (sort (map char->integer (string->list (~v x)))
                                 <))
                    48)))
         (define (g y)
           (if
             (= y (m y))
             y
             (g (m y))))
         (define (k x l)
           (if (= (length l) n)
               l
               (if (< x (g x))
                   (k (+ x 1) (cons x l))
                   (k (+ x 1) l))))
    (reverse (k 1 '()))))

Galen Ivanov

Posted 2018-10-14T20:20:55.233

Reputation: 13 815

0

Axiom, 168 bytes

u(x)==(y:=x::String;x^reduce(min,[ord(y.i)-48 for i in 1..#y])::NNI)
q(a:PI):PI==(b:=a;repeat(c:=u(b);c=b=>break;b:=c);b)
z(x)==[i for i in 1..x|(m:=q(i))~=1 and m~=i]

The function to use it is z(); here it print numbers that has the corrispondence one number not 1, not itself and are less than its argument.

(6) -> z 1000
 (6)
 [3, 5, 6, 8, 23, 26, 27, 29, 35, 36, 39, 42, 47, 53, 59, 64, 72, 76, 78, 82,
  83, 84, 92, 222, 223, 227, 228, 229, 233, 237, 239, 254, 263, 267, 268,
  269, 273, 276, 277, 278, 279, 285, 286, 287, 289, 296, 335, 338, 339, 342,
  346, 347, 348, 354, 358, 363, 365, 372, 373, 374, 376, 382, 383, 386, 392,
  394, 395, 399, 423, 424, 426, 427, 428, 432, 433, 435, 436, 442, 447, 459,
  462, 464, 466, 467, 468, 469, 476, 477, 479, 483, 487, 488, 489, 493, 494,
  523, 524, 527, 529, 533, 537, 542, 546, 553, 556, 557, 562, 563, 572, 573,
  577, 582, 583, 584, 594, 595, 598, 623, 626, 627, 629, 632, 633, 642, 646,
  647, 648, 663, 664, 669, 672, 676, 682, 683, 684, 693, 694, 695, 698, 722,
  724, 729, 736, 759, 763, 773, 775, 782, 786, 823, 829, 835, 846, 847, 856,
  873, 876, 885, 893, 894, 896, 923, 924, 928, 933, 953, 954, 962, 969, 973,
  974, 984, 993, 994, 995]
                                               Type: List PositiveInteger

RosLuP

Posted 2018-10-14T20:20:55.233

Reputation: 3 036

0

Visual Basic .NET (.NET Core), 290 bytes (includes imports)

Iterator Function A()As System.Collections.IEnumerable
Dim i=B.One,q=i,p=i
While 1=1
q=i-1
p=i
While q<>p
For j=0To 9
If p.ToString.Contains(j)Then
q=p
p=B.Pow(p,j)
Exit For
End If
Next
End While
If p>1And p<>i Then Yield i
i+=1
End While
End Function

Try it online!

Requires the following import:

Imports B = System.Numerics.BigInteger

This uses an iterator function to return an infinite (lazy loaded) list of integers that meets the criteria. Uses BigInteger to avoid any size restrictions, particularly with intermediate calculations.

Un-golfed:

Iterator Function A() As System.Collections.IEnumerable
    Dim i As B = 1
    While True
        Dim prevProduct As B = 0
        Dim product As B = i
        While prevProduct <> product
            For j = 0 To 9
                If product.ToString.Contains(j) Then
                    prevProduct = product
                    product = B.Pow(product, j)
                    Exit For
                End If
            Next
        End While
        If product <> 1 And product <> i Then
            Yield i
        End If
        i += 1
    End While
End Function

Brian J

Posted 2018-10-14T20:20:55.233

Reputation: 653

0

Common Lisp, 238 bytes

(defun x(m n o p q)(setf i(sort(map 'list #'digit-char-p(prin1-to-string m))#'<))(setf j(expt m(first i)))(cond((= q p)nil)((and(= n j)(not(= n 1))(not(= n o)))(cons o(x(1+ o)0(1+ o)p(1+ q))))((= n j)(x(1+ o)0(1+ o)p q))(t(x j j o p q))))

Try it online!

JRowan

Posted 2018-10-14T20:20:55.233

Reputation: 231

0

APL(NARS), 96 chars, 192 bytes

r←f w;k;i;a
   r←⍬⋄k←1
A: i←k
B: →C×⍳i=a←i*⌊/⍎¨⍕i⋄i←a⋄→B
C: →D×⍳(a=k)∨a=1⋄r←r,k
D: k+←1⋄→A×⍳k≤w

test (partial result for argument 22 seems to much big so <21 arguments I don't know if can be ok)

  f 21
3 5 6 8 

RosLuP

Posted 2018-10-14T20:20:55.233

Reputation: 3 036

0

Python 3, 102 bytes

x=int(input())
a=c=0
while x:
 a+=1;b=a
 while b-c:b,c=b**int(min(str(b))),b
 x-=b!=1and b!=a
print(a)

Try it online!

Decided to try a Python 3 solution that directly prints the nth term in the sequence.

JosiahRyanW

Posted 2018-10-14T20:20:55.233

Reputation: 2 600

Looks like you're not using any Python 3 features. Quick golfing in Python 2 gives 87 bytes.

– Bubbler – 2018-10-16T06:56:02.640

Infinite output gives 77 bytes. – Bubbler – 2018-10-16T07:02:39.333

0

Japt, 44 bytes


_ì ñ g
_gV ¥1?Z:ZpZgV)gW
@@[1X]øXgW}fXÄ}gUÄ

Try it online!

Substantially different from the other Japt answer.

Explanation:

                        Empty line preserves the input

_ì ñ g                Function V finds the smallest digit in a number Z
 ì                          Get the digits of Z
   ñ                        Sort the digits
     g                      Get the first (smallest) digit


_gV ¥1?Z:ZpZgV)gW     Function W finds the MPR of a number Z
 gV ¥1?Z                    If V(Z) is 1, then it's stable; return it
        :ZpZgV)             Otherwise get MPI of Z...
               gW           And call W on it ( MPR(Z) == MPR(MPI(Z)) )

@@[1X]øXgW}fXÄ}gUÄ    Main program
@             }gUÄ      Get the nth number by repeatedly applying...    
 @        }fXÄ              Find the next smallest number X which returns false to...
       XgW                    MPR(X)
      ø                       is either...
  [1X]                        1 or X

In terms of future golfing possibilities, I do a lot of manually calling a function on a number, which I suspect could be reduced but I'm not sure how.

Kamil Drakari

Posted 2018-10-14T20:20:55.233

Reputation: 3 461

0

Husk, 16 12 10 bytes

fS>ωṠ^o▼dN

Saved 6 bytes thanks to H.PWiz.
Try it online!

Explanation

fS>ωṠ^o▼dN
f        N       Filter the natural numbers where...
   ω             ... the fixed point...
    Ṡ^o▼d        ... of raising the number to its smallest digit...
 S>              ... is greater than the number.

user48543

Posted 2018-10-14T20:20:55.233

Reputation:

You can change here with S>. This allows you to put it all in one line. Also, it appears that you have mistakenly left in the previous tio link – H.PWiz – 2018-10-17T21:27:42.253

0

C (clang) + -DL=long long -lm, 213 bytes

q(char*a,char*b){return*a>*b;}L f(L a){char*c;asprintf(&c,"%lld",a);qsort(c,strlen(c),1,q);L b=pow(a,*c-48);return b>a?f(b):b;}i;g(j){for(i=0;j;i++){L x=f(i);x!=i&x!=1&x>0&&printf("%d\n",i)&&j--;}}

Try it online!

Function g(j) prints the first j terms of the sequence.

Logern

Posted 2018-10-14T20:20:55.233

Reputation: 845

Return with a=... to save a dozen or so bytes. – None – 2018-10-20T12:05:29.900

And x>1 instead of x!=1&x>0. – None – 2018-10-20T12:13:25.110

The first one requires a change to GCC, though. – None – 2018-10-20T12:20:27.177

0

Python 3, 54 bytes

lambda n,x=0:n!=x and f(n**min(map(int,str(n))),n)or n

Try it online!

mabel

Posted 2018-10-14T20:20:55.233

Reputation: 1 489

0

Burlesque, 35 bytes

r0f{J{J<]**}{J<]1!=}w!J1!=x/x/!=&&}

Try it online!

"Produces" the infinite list of MPRs (i.e. never finishes, never prints). For a finite list use:

Burlesque, 36 bytes

ri{J{J<]**}{J<]1!=}w!J1!=x/x/!=&&}FO

Try it online!

Takes an integer input N and tests the first N values

r0      # All integers starting from 0
f{      # Filter for
 J      # Duplicate original value (for later)
 {
  J     # Duplicate current value
  <]    # Minimum digit
  **    # Raise current value to power of min digit
 }
 {
  J<]   # Find minimum digit (non-destructive)
  1!=   # Not equal to 1
 }w!    # While current value does not contain 0 or 1
 J      # Duplicate output
 1!=    # Not equal to 1
 x/x/   # Reorganise stack
 !=     # Output is not equal to original
 &&     # AND not equal to 1
}

DeathIncarnate

Posted 2018-10-14T20:20:55.233

Reputation: 916

0

Dash (or other generic Bourne shell) + bc, 190 bytes

a=0
while :
do
a=`echo $a+1|bc`
b=$a
while :
do
for m in `seq 0 9`
do
case "$b" in
*$m*)break;;
esac
done
case $m in
0)break;;
1)[ $a = $b ]||echo $a;break;;
esac
b=`echo $b^$m|bc`
done
done

Try it online!

This implementation prints the infinite sequence -- as far as it is allowed.

I specifically did not use bash arithmetic because I didn't want the limit of bash's number system. If you change the line a=0 to a=$1, you can start looking at any number (though subtract 1 if you want the first number considered). Passing in 9922289264447635429194, I found part of the sequence is:

9922289264447635429236
9922289264447635429254
9922289264447635429323
9922289264447635429328
9922289264447635429335

David G.

Posted 2018-10-14T20:20:55.233

Reputation: 541

I thought those were just floating-point errors in my program... – S.S. Anne – 2020-02-05T22:35:56.887

@S.S.Anne well, it is trivial to get huge numbers in the calculation. 22 -> 484 -> 54875873536 -> 165251092644282265779977014214656 -> 1. And I avoided them by using bc and treating the numbers as strings. But I also wanted to be able to get numbers in the sequence exceeding what an integer could represent. Ideally, your program should have no floating point values. – David G. – 2020-02-05T22:48:07.427

Well it uses pow (exponentiation) which is only available for floating-point numbers. – S.S. Anne – 2020-02-05T23:24:30.853

@S.S.Anne. right, but there is a limit to precision. on x86, you actually get as much precision just multiplying the unsigned long longs as using powl(). On other platforms (my Raspberry PI) you get more. Having said that, you nominally need 108 bits of precision to verify 22 is not in the sequence. If you are lucky enough to get a 0 in the first 10-12 digits, ok, but otherwise... – David G. – 2020-02-06T00:51:40.450