Have you ever stopped to wonder exactly how much light has been produced by all the stars in the Universe, over all the time that has passed? Well, now you can wonder no more. An international team of astronomers has actually calculated the amount of starlight in the cosmos.

And it's teaching us new things about the early years of our Universe.

In the time since the Big Bang - roughly 13.7 billion years - our Universe has produced many, many galaxies, and many more stars. Perhaps around two trillion galaxies, containing around a trillion-trillion stars.

For decades, scientists have known that knowing how much light these stars have produced over the course of the Universe's lifespan would be a powerful tool for understanding the early Universe, as well as the history of star formation.

But, well, it's not exactly an easy thing to measure. While there are a lot of stars out there, producing many photons, space is incredibly vast, and starlight incredibly dim. There's also interference from zodiacal light and the Milky Way's own faint glow. The Universe's starlight cannot really be observed directly.

But astrophysicist Marco Ajello of Clemson University and his team discovered an indirect method of quantifying starlight. They used gamma ray photons.

"These are photons that are high energy, typically a billion times the energy of visible light," Ajello told ScienceAlert.

"While travelling through space, gamma rays can be absorbed through interactions with starlight photons. And if there are many starlight photons, there will be more absorptions; so we can count the number of absorptions that we see to understand the density of the starlight of the photon field between us and the gamma ray source."

Using nine years' worth of data from NASA's Fermi Gamma-ray Space Telescope, Ajello and his team analysed the light from 739 blazars (strong gamma-ray sources) throughout the Universe to determine the rate of absorption into the extragalactic background light (EBL), the Universe's accumulated background radiation.

This gave them the density of starlight photons in the EBL - and, because the blazars are at different distances, they were able to do so across a range of time periods.

Once they accounted for and subtracted light from other sources, such as the glowing accretion discs around supermassive black holes, they could multiply this density by the volume of the Universe to arrive at the number of photons produced by stars since the beginning of time.

"We basically have a tool, like a book, to tell the stories of starlight across the history of the Universe, and finally we found it, and we can just read it," Ajello said.

"So we did. We measured the entire star formation history of the Universe."

It is pretty simple to explain, but it was painstaking and complex to actually do. It took the team three years - and it was worth it.

We now know that, as of the time Fermi's data was collected, the Universe's stars had produced 4×1084 photons.

Yep, it's a four followed by 84 zeroes. That's a pretty cool trivia fact, so file it up your sleeve for later.

But you bet the science actually gets much cooler. Because that cool number actually lifts the veil on a particularly mysterious time in our Universe's history - the Epoch of Reionisation, which started around 500 million years after the Big Bang. We often hear the term "holy grail" chucked around, but the EoR really IS one.

It's basically when the Universe's lights switched on.

Before the EoR, space was opaque. Then something came along and ionised all the neutral hydrogen, so that radiation - including light - could stream freely through the Universe.

"With our measurement, we can reach the very first billion years of the Universe, and that's a very interesting time of the Universe, so distant from us that all the really powerful telescopes can't really see. The objects there are so far away and so faint that we can't really see them. Instead, we still see the light from those objects," Ajello explained.

The team found two things of note in that time: a very large number of UV photons, which was expected for the reionisation process; and that the sources of those UV photons were populations of irregular galaxies - small, blobby, asymmetrical galaxies that produce a lot of UV radiation.

These could be the drivers behind reionisation. It's expected that the James Webb Space Telescope, scheduled for a 2021 launch, could tell us more about the EoR.

Meanwhile, Ajello and his team are going to apply their book of the stars to a deeper study of the cosmos - such as the rate of the Universe's expansion, the Hubble constant, which has been really difficult to pin down.

"It turns out our measurement is very sensitive to the expansion rate of the Universe," Ajello said. "This can be used to make a measurement of the Hubble Constant right now, so that's something that we're going to do."

The team's research has been published in the journal Science.