When counting in 4s, the number of marbles=4m+2 where m is a whole number.
When counting in 5s, the number of marbles=5n+1.
Therefore 4m+2=5n+1, 4m=5n-1, m=(5n-1)/4=(4n+n-1)/4=n+(n-1)/4.
For m to be a whole number, n-1 must be divisible by 4, that is, n=5, 9, 13, etc. So m would be 6, 11, 16, etc.
We can therefore find sets of values for the pair (n,m):
(n,m)={(5,6) (9,11) (13,16) (17,21) ...}
This gives the number of marbles to be 4m+2 or 5n+1.
For example, using (n,m)=(5,6), the number of marbles would be 26. If (n,m)=(9,11), the number of marbles would be 46; if (n,m)=(13,16), the number would be 66.
Note how the number of marbles increases by 20 for each successive (n,m) pair. 20 is 4 times 5.
We need a number between 20 and 50 so there are two solutions: 26 and 46 marbles.