rewritten function with returning set of Integer for task 5 lab 3