The fact that it is bootlooping isn't enough to identify the reason, so I can only make some generic suggestions.
First, is the battery OK? Just in case it's failing so badly that it can't complete the boot. Were you having any problems with the battery before this started, and is it even slightly swollen (it should be completely flat, if it has started to swell at all it is dangerous and should not be used).
Second, since you have done a factory reset the remaining option is to reload the system software (the two are completely different). You can find the firmware at sammobile.com, and install it with a program called kies or odin (I can't remember which, as I'm not a Samsung expert). You'll need the full model number of your phone to find the right software (there are many different S4 models).
Finally, although you've only had it for 3 months the S4 itself is almost 4 years old. So you can't be sure of that phone's history - this could be an age-related hardware fault, or the result of ill-treatment by a previous owner, you can't really know. If a firmware flash doesn't fix it then there isn't much else you can do (you could take it to a repair shop, but if they can fix it it might be expensive if they say all they can do is replace the motherboard).