I had the same problem a year ago with another computer.
It was the motherboard dying.
This could also be the processor, or PSU. Try an external videocard (plug one into PCIe, etc). RAM won't cause the computer to do this, but you should test/replace/reseat if possible.
Try testing your PSU, there's lots of good tutorials on YouTube- this will require a voltmeter.
The next step would be testing the processor in another computer(a hassle) or simply buying one off eBay and putting it in. You'll have to deal with the thermal paste, though.
Finally, you would have to try the motherboard, which is what fixed the problem for me.