Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

deleted 298 characters in body
Source Link
user202729
  • 17.6k
  • 2
  • 39
  • 71

J, 3734 bytes

(3431 as an expression without the assignment to variable f)

f=:1{(m&.:^.z,m&.:%%z,m&.:*:z,m=[z=:(+/%#)^:_

Try it online!

1{ Take the element #1 of
( the function
 m&.:^. {do "m" under natural logarithm}
 ,m&.:% {do "m" under inversion}
 ,m&&.:*: {do "m" under square}
 ,m=:+/%# {do "m"} - where m = arithmetic mean
)^:_ applied infinitely many times

Try it online!

For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.

J, 37 bytes

(34 as an expression without the assignment to variable f)

f=:1{(m&.:^.,m&.:%,m&.:*:,m=:+/%#)^:_

Try it online!

1{ Take the element #1 of
( the function
 m&.:^. {do "m" under natural logarithm}
 ,m&.:% {do "m" under inversion}
 ,m&.:*: {do "m" under square}
 ,m=:+/%# {do "m"} - where m = arithmetic mean
)^:_ applied infinitely many times

For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.

J, 34 bytes

(31 as an expression without the assignment to variable f)

f=:1{(^.z,%z,*:z,[z=:(+/%#)&.:)^:_

Try it online!

For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.

added 546 characters in body
Source Link
user202729
  • 17.6k
  • 2
  • 39
  • 71

J, 37 bytes

(34 as an expression without the assignment to variable f)

f=:1{(m&.:^.,m&.:%,m&.:*:,m=:+/%#)^:_

Try it online!

1{ Take the element #1 of
( the function
 m&.:^. {do "m" under natural logarithm}
 ,m&.:% {do "m" under inversion}
 ,m&.:*: {do "m" under square}
 ,m=:+/%# {do "m"} - where m = arithmetic mean
)^:_ applied infinitely many times

For functions a and b, a &.: b ("a under b" (related challenge )) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.

J, 37 bytes

(34 as an expression without the assignment to variable f)

f=:1{(m&.:^.,m&.:%,m&.:*:,m=:+/%#)^:_

Try it online!

J, 37 bytes

(34 as an expression without the assignment to variable f)

f=:1{(m&.:^.,m&.:%,m&.:*:,m=:+/%#)^:_

Try it online!

1{ Take the element #1 of
( the function
 m&.:^. {do "m" under natural logarithm}
 ,m&.:% {do "m" under inversion}
 ,m&.:*: {do "m" under square}
 ,m=:+/%# {do "m"} - where m = arithmetic mean
)^:_ applied infinitely many times

For functions a and b, a &.: b ("a under b" (related challenge )) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.

Source Link
user202729
  • 17.6k
  • 2
  • 39
  • 71

J, 37 bytes

(34 as an expression without the assignment to variable f)

f=:1{(m&.:^.,m&.:%,m&.:*:,m=:+/%#)^:_

Try it online!

AltStyle によって変換されたページ (->オリジナル) /