I think it is mostly inherited but external factors (school, parenting, etc) either make the most or least of it.
I have a co-worker that it one of 8 children. Out of the 8 children, 6 of them were class valedictorians and a few have IQs above or near 160. This trend also seems to be "popping" up in some of the kids now. I don't think they are doing anything different at home than the most people.