  We show that an n-dimensional generalized Robertson-Walker (GRW) space-time
with divergence-free conformal curvature tensor exhibits a perfect fluid
stress-energy tensor for any f(R) gravity model. Furthermore we prove that a
conformally flat GRW space-time is still a perfect fluid in both f(R) and
quadratic gravity where other curvature invariants are considered.
