Skip to main content
added 33 characters in body
Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

Python 3.8, 91 bytes

import math f=lambda n,m,N=0,D=1:n and f(n-1,m,N*n**m+D,D*n**m)or(N/(G:=math.gcd(N,D)),D/G) 

Try it online!

Inputs \$n\$ and \$m\$ and returns the numerator and denominator of \$H_{n,m}\$ as a tuple.

Uses the formula from Arnauld's JavaScript answer.

Python 3.8, 91 bytes

import math f=lambda n,m,N=0,D=1:n and f(n-1,m,N*n**m+D,D*n**m)or(N/(G:=math.gcd(N,D)),D/G) 

Try it online!

Inputs \$n\$ and \$m\$ and returns \$H_{n,m}\$ as a tuple.

Uses the formula from Arnauld's JavaScript answer.

Python 3.8, 91 bytes

import math f=lambda n,m,N=0,D=1:n and f(n-1,m,N*n**m+D,D*n**m)or(N/(G:=math.gcd(N,D)),D/G) 

Try it online!

Inputs \$n\$ and \$m\$ and returns the numerator and denominator of \$H_{n,m}\$ as a tuple.

Uses the formula from Arnauld's JavaScript answer.

Source Link
Noodle9
  • 20.4k
  • 3
  • 23
  • 47

Python 3.8, 91 bytes

import math f=lambda n,m,N=0,D=1:n and f(n-1,m,N*n**m+D,D*n**m)or(N/(G:=math.gcd(N,D)),D/G) 

Try it online!

Inputs \$n\$ and \$m\$ and returns \$H_{n,m}\$ as a tuple.

Uses the formula from Arnauld's JavaScript answer.