Researchers with the U.S. Army have come with an algorithm that can determine the perfect amount of caffeine a person needs to drink to stay at maximum alertness, according to a study published last month in the Journal of Sleep Research.

>> Read more trending news

The study’s lead author, Jaques Reifman, a senior research scientist with the U.S. Army, said the algorithm is the first of its kind.

Researchers used a mathematical model that predicts the effects of sleep loss and caffeine on a person’s attention and reaction time, combined with the algorithm to determine “when and how much caffeine to consume to safely maximize alertness during sleep loss,” according to the American Academy of Sleep Medicine.

Researchers presented their findings Monday at SLEEP 2018, the annual meeting of the Associated Professional Sleep Societies LLC, a joint venture of the American Academy of Sleep Medicine and the Sleep Research Society.

The algorithm used a person’s sleep and wake schedule along with his or her “maximum allowed caffeine” to determine the perfect caffeine-dosing strategy, according to the study authors.

“We found that by using our algorithm, which determines when and how much caffeine a subject should consume, we can improve alertness by up to 64 percent, while consuming the same total amount of caffeine,” Reifman said. “Alternatively, a subject can reduce caffeine consumption by up to 65 percent and still achieve equivalent improvements in alertness.”

The Army is already using the algorithm for its soldiers-in-training and has plans to license it for wider use as a smartphone app, Government Technology magazine reported.

Scientists first published the study, "Caffeine dosing strategies to optimize alertness during sleep loss," May 28 in the Journal of Sleep Research.