Answer:
Ahh! What a classic: Systems of Equations!
So, if you don't know what a system of equations is, its basically two equations with two variables combined into a system.
So, let x=# of pigs
And also, Let y=# of chickens
Let's make our first equation!
![13=x+y](https://img.qammunity.org/2021/formulas/mathematics/middle-school/r36mdhad8tk1jmvc73qkie3v3jv1zwr1zu.png)
This is because there are 13 animals in a barn.
So then, knowing that a pig has 4 legs and a chicken 2:
![40=4x+2y](https://img.qammunity.org/2021/formulas/mathematics/middle-school/ge1mkpde3sx2tjx0v7s1pbxlslk2bel58r.png)
This is because there are 40 legs in total, and we multiply the variable because that's how many legs each creature has.
So, here is our system!
![\left \{ {{x+y=13} \atop {4x+2y=40}} \right.](https://img.qammunity.org/2021/formulas/mathematics/middle-school/lbuwiaztrguqubghcbj8azml8f8y677rn5.png)
Through Substitution (the inputting of something instead of a variable):
![x+y=13\\x=13-y](https://img.qammunity.org/2021/formulas/mathematics/middle-school/m4ehukyxhl3eju784b9bujw2vupi9i6o36.png)
Then, we input it into the next equation:
![4(13-y)+2y=40\\52-4y+2y=40\\-2y=-12\\y=6](https://img.qammunity.org/2021/formulas/mathematics/middle-school/1qp57zm08taoogq84ziile1i3t87dh8vig.png)
This means that there are 6 chickens, and by inputting it into the first equation:
![x+6=13\\x=7](https://img.qammunity.org/2021/formulas/mathematics/middle-school/543ia3o6sfmtkaay983emsn1124zqt4s7r.png)
So there you have it!
FYI there are 6 chickens and 7 pigs.
Hope this helps!
P.S. Stay Safe!