Heavy slam works like this:
User's weight / Target's weight
If the use is 5 times heavier or more, it will do 120 base power which is the maximum.
4 times = 100
3 times = 80
2 times = 60
1 times= 40 (minimum damage)
A gastly will do 40 base power if it was able to learn heavy slam.
Edit: Don't forget that it's a steel type physical attack. So physical stats and the target's type matters.