To solve this problem we can use equation.
If we assume that x is number of crocodiles, we can say that number of alligators is 4*x because its 4 times more.
We know that together is 40, so we have
x+4*x=40
Now we are reducing.
5x=40 /:5 dividing both sides by 5
x=9 - number of alligators