'Is there a way to return integers separated by space from a function whose return type is int?

so I took this OA for an interview and one of the questions was:

given an input of a bunch of integers, sum them up and return those input integers that the sum isn't divisible by.

For example if our input is:

1 2 3 4 5 our output should be 2 4, since the sum is 15 and 1 3 and 5 can divide 15.

The issue was the return type of the function in which I had to write this was int, and I was supposed to return all the integers separated by space. An array or tuple of the integers would not satisfy the requirement.

Any help? I could choose any language to solve this so it's not a language specific question.



Solution 1:[1]

I don't think most languages allow for non-int characters to be returned in the int data type. Perhaps use 0 instead of space so in this case return 204.

Solution 2:[2]

You can try to print them with “for” cycle on one line separated with space.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sean1441
Solution 2 chepilov