The ratio of the number of marbles received by John and Peter was 4:7 respectively.

The ratio of the number of marbles received by Peter and Sam was 9:5. John gave
1/12 of his marbles to Sam. Peter gave 1/9 of his marbles to Sam. Eventually, Sam
had 135 marbles.

(a) Find the ratio of the number of John's marbles to Sam's marbles at first.

(b) Find the total number of marbles received by the 3 boys.

J : P = 4:7 and P : S = 9:5

We want the same number at P, this is like LCM for 7 and 9 which is 63

J:P = 36:63 and P:S = 63:35

then : J : P : S = 36 : 63 : 35 = 36x : 63x : 35x

a) John : Sam = 36x : 35x = 36 : 35

"John gave 1/12 of his marbles to Sam"
so J has 18x marbles and S has 53x

"Peter gave 1/9 of his marbles to Sam" , 1/9 of 63x is 7x
J now has 18x, P has 56x and S has 60x,
final ratio = J : P : S = 18x : 56x : 60x

so 60x = 135
x = 135/60 = 2.25

at first J : P : S = 36x : 63x : 35x
at last: J : P : S = 18x : 56x : 60x = 40.5 : 126 : 135
....... can't have partial marbles, but the 135 matches !!!!

Total number of marbles = 36x + 63x + 35x = 134x
(notice after the gifting we have 18x + 56x + 60x = 134x, all we did was shuffle them around, so that's fine)

so total marbles between all the boys = 134x = 134(2.25) = not a whole number!!!!

Unless I have an error in my arithmetic, there appears to be
flaw in the data given.