Creating main program that simulates the algorithm.