School project. Simulates the math behind