From Bulbapedia:
"To get larger Spheres, they can be combined by burying more than one of the same color Sphere in the same spot. When combined, the size of the resulting Sphere is determined by the following formula:
X + (a⁄5+1) + (b⁄5+1) + (c⁄5+1)...
Unless the buried Sphere has grown at least once since a Sphere was added (or grown without a Sphere being added), in which case the formula is:
B + X + (a⁄5+1) + (b⁄5+1) + (c⁄5+1)...
Where B is the size of a grown buried Sphere, X is the size of the otherwise largest Sphere buried, and a, b, c, and so on are the sizes of the other Spheres. All non-integer values are rounded down before the adding. In the event of a tie for the largest size, the largest Sphere size is used both as X and one of the other lowercase variables. For instance, burying a Prism Sphere 15, a Prism Sphere 12, a Prism Sphere 7, and two Prism Sphere 1s produces a Prism Sphere 22. Burying a Blue Sphere 15, Blue Sphere 3, Blue Sphere 22, on top of a Blue Sphere 3 that has grown by 2 yields a Blue Sphere 32."
Hope that helps!