After attending the Academy at Edinburgh and spending a session at the University, he went up to Cambridge as a member of Peterhouse, and graduated as senior wrangler and first Smith's prizeman in 1852.
Before he was sixteen he attended lectures at Owens College, and at eighteen he gained a mathematical scholarship at Trinity College, Cambridge, where he graduated in 1871 as senior wrangler and first Smith's prizeman, having previously taken the degree of D.Sc. at London University and won a Whitworth scholarship. Although elected a fellow and tutor of his college, he stayed up at Cambridge only for a very short time, preferring to learn practical engineering as a pupil in the works in which his father was a partner.
In the same year he was elected a fellow of Trinity College, and became second Smith's prizeman.
At Cambridge, Leonard Courtney was second wrangler and first Smith's prizeman, and was elected a fellow of his college, St John's.
He graduated in 1769, with the rank of third wrangler and first Smith's prizeman.