How can I use Mathematica to perform sums with the condition of divisibility?

  • Context: Mathematica 
  • Thread starter Thread starter MathematicalPhysicist
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
SUMMARY

This discussion focuses on using Mathematica to perform summations with divisibility conditions, specifically the summation of divisors of a number \( n \). The user seeks guidance on implementing the condition \( d|n \) in Mathematica's Sum function. The solution involves defining a term that evaluates to zero unless \( d \) divides \( n \), utilizing the modulus arithmetic command. An example provided is the summation for \( n=12 \), resulting in \( a + a^2 + a^3 + a^4 + a^6 \).

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of divisibility and divisor functions
  • Knowledge of modulus arithmetic
  • Basic algebraic manipulation of summations
NEXT STEPS
  • Explore advanced features of Mathematica's Sum function
  • Learn about defining custom functions in Mathematica
  • Investigate the use of If statements within summations
  • Study the properties of divisors and their applications in number theory
USEFUL FOR

Mathematics students, educators, and researchers interested in computational mathematics and number theory, particularly those using Mathematica for symbolic calculations.

MathematicalPhysicist
Science Advisor
Gold Member
Messages
4,662
Reaction score
372
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
You need to define term as a function of d and n such that "term = 0 unless d|n." Look into modulus arithmetic commands.
 
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
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
7K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K