J, 26 bytes
_(]+1-1</@(=],+./)q:)^:_>:
I started with the "do-until" idiom f^:g^:_ with g boolean (apply f while g is true), but soon realized that the "find next integer" can be written in a single fixpoint (]+1-g)^:_. The only problem is that we don't have a straightforward/more golfy way to express the boolean negation of g other than 1-g.
How it works
_(]+1-1</@(=],+./)q:)^:_>: NB. Input: n
>: NB. n+1
_( )^:_ NB. Fixpoint with left arg of _ (infinity)...
q: NB. (_ q: n) gives prime exponents including zeros
NB. _ q: 700 -> 2 0 2 1 (2^2 * 5^2 * 7^1)
( ],+./) NB. Append GCD of ^ to itself
1 = NB. Test if each number equals 1 (gives boolean vector)
</@ NB. Test if the only 1 is the last item
]+1- NB. Negate the condition and add to the input number
J, 26 bytes
_(]+1-1</@(=],+./)q:)^:_>:
I started with the "do-until" idiom f^:g^:_ with g boolean (apply f while g is true), but soon realized that the "find next integer" can be written in a single fixpoint (]+1-g)^:_. The only problem is that we don't have a straightforward/more golfy way to express the negation of g other than 1-g.
How it works
_(]+1-1</@(=],+./)q:)^:_>: NB. Input: n
>: NB. n+1
_( )^:_ NB. Fixpoint with left arg of _ (infinity)...
q: NB. (_ q: n) gives prime exponents including zeros
NB. _ q: 700 -> 2 0 2 1 (2^2 * 5^2 * 7^1)
( ],+./) NB. Append GCD of ^ to itself
1 = NB. Test if each number equals 1 (gives boolean vector)
</@ NB. Test if the only 1 is the last item
]+1- NB. Negate the condition and add to the input number
J, 26 bytes
_(]+1-1</@(=],+./)q:)^:_>:
I started with the "do-until" idiom f^:g^:_ with g boolean (apply f while g is true), but soon realized that the "find next integer" can be written in a single fixpoint (]+1-g)^:_. The only problem is that we don't have a straightforward/more golfy way to express the boolean negation of g other than 1-g.
How it works
_(]+1-1</@(=],+./)q:)^:_>: NB. Input: n
>: NB. n+1
_( )^:_ NB. Fixpoint with left arg of _ (infinity)...
q: NB. (_ q: n) gives prime exponents including zeros
NB. _ q: 700 -> 2 0 2 1 (2^2 * 5^2 * 7^1)
( ],+./) NB. Append GCD of ^ to itself
1 = NB. Test if each number equals 1 (gives boolean vector)
</@ NB. Test if the only 1 is the last item
]+1- NB. Negate the condition and add to the input number
J, 26 bytes
_(]+1-1</@(=],+./)q:)^:_>:
I started with the "do-until" idiom f^:g^:_ with g boolean (apply f while g is true), but soon realized that the "find next integer" can be written in a single fixpoint (]+1-g)^:_. The only problem is that we don't have a straightforward/more golfy way to express the negation of g other than 1-g.
How it works
_(]+1-1</@(=],+./)q:)^:_>: NB. Input: n
>: NB. n+1
_( )^:_ NB. Fixpoint with left arg of _ (infinity)...
q: NB. (_ q: n) gives prime exponents including zeros
NB. _ q: 700 -> 2 0 2 1 (2^2 * 5^2 * 7^1)
( ],+./) NB. Append GCD of ^ to itself
1 = NB. Test if each number equals 1 (gives boolean vector)
</@ NB. Test if the only 1 is the last item
]+1- NB. Negate the condition and add to the input number