In fact, there is modern evidence to support this hypothesis. There is a tribe in Kenya called the Ariaal, who were traditionally nomadic animal herders. More recently, a subgroup split off and settled in one location, where they practice agriculture. Dan T. A. Eisenberg, an anthropologist at the University of Washington, examined the frequency of a genetic variant of the dopamine type-four receptor called DRD4 7R in the nomadic and settler groups of the Ariaal. This genetic variant makes the dopamine receptor less responsive than normal and is specifically linked with A.D.H.D. Dr. Eisenberg discovered that the nomadic men who had the DRD4 7R variant were better nourished than the nomadic men who lacked it. Strikingly, the reverse was true for the Ariaal who had settled: Those with this genetic variant were significantly more underweight than those without it.

So if you are nomadic, having a gene that promotes A.D.H.D.-like behavior is clearly advantageous (you are better nourished), but the same trait is a disadvantage if you live in a settled context. It’s not hard to see why. Nomadic Ariaal, with short attention spans and novelty-seeking tendencies, are probably going to have an easier time making the most of a dynamic environment, including getting more to eat. But this same brief attention span would not be very useful among the settled, who have to focus on activities that call for sustained focus, like going to school, growing crops and selling goods.

You may wonder what accounts for the recent explosive increase in the rates of A.D.H.D. diagnosis and its treatment through medication. The lifetime prevalence in children has increased to 11 percent in 2011 from 7.8 percent in 2003 — a whopping 41 percent increase — according to the Centers for Disease Control and Prevention. And 6.1 percent of young people were taking some A.D.H.D. medication in 2011, a 28 percent increase since 2007. Most alarmingly, more than 10,000 toddlers at ages 2 and 3 were found to be taking these drugs, far outside any established pediatric guidelines.

Some of the rising prevalence of A.D.H.D. is doubtless driven by the pharmaceutical industry, whose profitable drugs are the mainstay of treatment. Others blame burdensome levels of homework, but the data show otherwise. Studies consistently show that the number of hours of homework for high school students has remained steady for the past 30 years.

I think another social factor that, in part, may be driving the “epidemic” of A.D.H.D. has gone unnoticed: the increasingly stark contrast between the regimented and demanding school environment and the highly stimulating digital world, where young people spend their time outside school. Digital life, with its vivid gaming and exciting social media, is a world of immediate gratification where practically any desire or fantasy can be realized in the blink of an eye. By comparison, school would seem even duller to a novelty-seeking kid living in the early 21st century than in previous decades, and the comparatively boring school environment might accentuate students’ inattentive behavior, making their teachers more likely to see it and driving up the number of diagnoses.

Not all the news is so bad. Curiously, the prevalence of adult A.D.H.D. is only 3 to 5 percent, a fraction of what it is in young people. This suggests that a substantial number of people simply “grow out” of it. How does that happen?

Perhaps one explanation is that adults have far more freedom to choose the environment in which they live and the kind of work they do so that it better matches their cognitive style and reward preferences. If you were a restless kid who couldn’t sit still in school, you might choose to be an entrepreneur or carpenter, but you would be unlikely to become an accountant. But what is happening at the level of the brain that may explain this spontaneous “recovery”?