For a small angle of incidence the shift S is
S=(1−1μ)Δt
where μ is the refractive index, and Δt is the thickness.
So the total shift due to all the slabs will be given as,
S=S1+S2+S3+ . . . +Sn
S=Δt1[1−1μ]+Δt2[1−1μ]+...+Δtn[1−1μ]
As the thickness of the slabs is given as 1 cm,2 cm,...n cm we have
S=[1−1μ](1+2+...+n)
Now the refractive index is given as μ=1.5=32 and the total shift is given as S=5 cm
5=(1−23)(n(n+1)2)
30=n(n+1)
5×6=n(n+1)
⇒n=5