still trying to figure out the logic

argh so bad at math