Created method calculating squares recursively.