The first thing to note is that the IF formula doesn't need to pay attention to the row number - the result the formula returns only depends on the column.
So, in English the formula does this:
If the column header is 3 Or 4 Or 7 Or 8, Then Return 1. Otherwise return 0.
This is your homework, so I'm not going to just give you the formula. Have a look through your class notes and have a stab at it. There are several ways to do it, but I expect your teacher expects you to do it using the OR() function nested inside an IF() function.
Have a go and post back with what you've tried if you have no success.