Solution without the use of strings/concatenation