Skip to main content
edited body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

05AB1E, 25 bytes

æ¦ε.¿DIāÉ-s÷D>*2÷Æ®ygmP}O 

Try it online!

æ¦ε } # map over each non-empty subset of the divisors .¿D # take the GCDLCM of the subset IāÉ- # push the range with the lower bound decreased s÷ # integer divide modified range by GCDLCM D>*2÷ # for both resulting integers, compute the nth triangular number Æ # reduce by subtraction (results in negative values) ®ygm* # multiply with GCDLCM and (-1)**len(subset) O # sum the resulting list 

05AB1E, 25 bytes

æ¦ε.¿DIāÉ-s÷D>*2÷Æ®ygmP}O 

Try it online!

æ¦ε } # map over each non-empty subset of the divisors .¿D # take the GCD of the subset IāÉ- # push the range with the lower bound decreased s÷ # integer divide modified range by GCD D>*2÷ # for both resulting integers, compute the nth triangular number Æ # reduce by subtraction (results in negative values) ®ygm* # multiply with GCD and (-1)**len(subset) O # sum the resulting list 

05AB1E, 25 bytes

æ¦ε.¿DIāÉ-s÷D>*2÷Æ®ygmP}O 

Try it online!

æ¦ε } # map over each non-empty subset of the divisors .¿D # take the LCM of the subset IāÉ- # push the range with the lower bound decreased s÷ # integer divide modified range by LCM D>*2÷ # for both resulting integers, compute the nth triangular number Æ # reduce by subtraction (results in negative values) ®ygm* # multiply with LCM and (-1)**len(subset) O # sum the resulting list 
deleted 3 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

05AB1E, 2625 bytes

æ¦ε.¿DIāÉ-s÷D>*2÷Æ*®ygm*s÷D>*2÷Æ®ygmP}O 

Try it online!Try it online!

æ¦ε } # map over each non-empty subset of the divisors .¿D # take the GCD of the subset IāÉ- # push the range with the lower bound decreased s÷ # integer divide modified range by GCD D>*2÷ # for both resulting integers, compute the nth triangular number Æ # reduce by subtraction (results in negative values) ®ygm* # multiply with GCD and (-1)**len(subset) O # sum the resulting list 

05AB1E, 26 bytes

æ¦ε.¿DIāÉ-s÷D>*2÷Æ*®ygm*}O 

Try it online!

05AB1E, 25 bytes

æ¦ε.¿DIāÉ-s÷D>*2÷Æ®ygmP}O 

Try it online!

æ¦ε } # map over each non-empty subset of the divisors .¿D # take the GCD of the subset IāÉ- # push the range with the lower bound decreased s÷ # integer divide modified range by GCD D>*2÷ # for both resulting integers, compute the nth triangular number Æ # reduce by subtraction (results in negative values) ®ygm* # multiply with GCD and (-1)**len(subset) O # sum the resulting list 
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

05AB1E, 26 bytes

æ¦ε.¿DIāÉ-s÷D>*2÷Æ*®ygm*}O 

Try it online!