Summing in Mathematica.

  • Mathematica
  • Thread starter MathematicalPhysicist
  • Start date
  • Tags
    Mathematica
  • #1

MathematicalPhysicist

Gold Member
4,699
369
I want to write down summation of the type
[tex]\sum_{d|n , d<n}[/tex] or [tex]\sum_{d|n}[/tex] both summing over d.
and d|n means d divides n.

I know that I can use Sum[term, {i, n-1}] but I don't know how to use this condition of divisibility to the summation.
any help?

Thanks.
 
Physics news on Phys.org
  • #2
You need to define term as a function of d and n such that "term = 0 unless d|n." Look into modulus arithmetic commands.
 
  • #3
In[1]:= n=12; Sum[If[Mod[n,d]==0,a^d,0],{d,n-1}]

Out[1]= a + a^2 + a^3 + a^4 + a^6
 

Suggested for: Summing in Mathematica.

Replies
1
Views
704
Replies
1
Views
764
Replies
1
Views
1K
Replies
2
Views
1K
Replies
3
Views
76
Replies
1
Views
688
Replies
1
Views
957
Back
Top