Probably you will need to work with Measure Inertia workbench in order to measure the volumes of the Jar and Jelly Bean and then you can simply divide the values.
You will also have to apply some packing density fudge factor to get a reasnoble estimate (i.e. jelly beans are not going to tesserlate exactly into the jar)
Approximation based on a bit of empirical studies is probably your best bet unless you want the complexity-level to increase drastically.
If you are really looking to find the optimal packing for a set of objects with an arbitrary shape (jelly bean) withing a given volume you should look into Space Packing algorithms. But for large sets this can take a long time so is better done in more optimized code, not script.
Daniel Bosia at Arup AGU has done some interesting work in this field -> Watercube Stadium in Beijing amongst others