My computer turns on and off every 6 seconds?

So today, basically I went to do my homework on my computer and it came on to say "Sorry, There was an error with your PC, we will have to restart for you." So, I wait for it to restart and it turns off. I press the power button and it turned on for like 0.5 seconds and turned off for 6 seconds and kept repeating. I tried unplugging it and even took the cover off to take a look at it and my fan it moving ang stopping at the same time the on and off cycle is happening. I have a Thinkcentre M-series. Can someone please help me?

You probably have a virus. You should take it to geek squad.

Looks like you need to take it to a repair shop. It could be a number of tings, nottheleastofwhich being overheating, which can be caused by a numerable list of things.
a pro can spot the problem much faster…

A) take OUT everything out of the case.
B) Place mobo on wood board or a cardboard box
C) Remove ram, CPU from mobo. Reseat the CPU and 1 stick of RAM
D) Plug in the Case on off switch to mobo, connect PSU to ONLY the Mobo
E) plug in Video to onboard video (?) or add on GPU if no mobo-video
F) What happens now? If same, then try other PSU.
1) if same on both PSU, remove RAM, restart do you get error code beeps for 'problem with RAM' ? If not then the Mobo is faulty.
2) If RAM error beeps, try RAM in each slot, one at a time, then if still NOTHING, try other stick of RAM, same way, can you get it to work? If so then one stick of RAM is bad
3) If still no luck then remove CPU again, power on does it error boot code for the CPU? If not then Mobo is faulty. If it does then most likely the CPU is DEAD. To confirm CPU dead you have to test in another PC.

Check your settings

Start
Power Options
Make changes here

I have all my options set to never

Throw your worthless computer away.

This sounds like a problem caused by electrical shortage inside your computer. Try opening up the the computer by grabbing the button on two sides of the think-center and lifting it up. Get a air duster (Do NOT use a vacuum) and spray off all excess dust. If that does not work try replacing the power supply and see if all connections are not loose.

DO NOT take it to a "geek squad" as they will try to rip you off. Take it to a friend with knowledge instead

Restart your computer in safe mode and run Malwarebytes in safe mode. It should help clean most of the trojans and malware out. While in safe mode. You will probably need to run another scan when you restart your computer.