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

added 193 characters in body
Source Link
alephalpha
  • 51.9k
  • 7
  • 75
  • 196

Pari/GP, 42 bytes

Using the built-in qfrep.

n->1+2*vecsum(Vec(qfrep([2,1;1,2],n^2,1)))

qfrep(q,B,{flag=0}): vector of (half) the number of vectors of norms from 1 to B for the integral and definite quadratic form q. If flag is 1, count vectors of even norm from 1 to 2B.

Try it online!

Pari/GP, 42 bytes

Using the built-in qfrep.

n->1+2*vecsum(Vec(qfrep([2,1;1,2],n^2,1)))

Try it online!

Pari/GP, 42 bytes

Using the built-in qfrep.

n->1+2*vecsum(Vec(qfrep([2,1;1,2],n^2,1)))

qfrep(q,B,{flag=0}): vector of (half) the number of vectors of norms from 1 to B for the integral and definite quadratic form q. If flag is 1, count vectors of even norm from 1 to 2B.

Try it online!

deleted 41 characters in body
Source Link
alephalpha
  • 51.9k
  • 7
  • 75
  • 196

Pari/GP, 4642 bytes

Based on OEISUsing the built-in A004016 qfrep.

n->1+6*sum>1+2*vecsum(i=1,n^2,sumdivVec(iqfrep([2,d1;1,kronecker(d2],3n^2,1)))

Try it online! Try it online!

Pari/GP, 46 bytes

Based on OEIS A004016.

n->1+6*sum(i=1,n^2,sumdiv(i,d,kronecker(d,3)))

Try it online!

Pari/GP, 42 bytes

Using the built-in qfrep.

n->1+2*vecsum(Vec(qfrep([2,1;1,2],n^2,1)))

Try it online!

Source Link
alephalpha
  • 51.9k
  • 7
  • 75
  • 196

Pari/GP, 46 bytes

Based on OEIS A004016.

n->1+6*sum(i=1,n^2,sumdiv(i,d,kronecker(d,3)))

Try it online!

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