Project-Euler is a project mainly written in ..., it's free.
Ruby code
http://projecteuler.net/
Problem name corresponds to the problem on Project Euler. The current problems posted are solved fully by the program. Comments within.
Note: the 2 marble problem solution set for the minimum value is also known as triangle numbers