Run a function n amount of times with a given interval pattern