QUINCY, Mass. — The mystery of the foul odor that’s been wafting over coastal Quincy for several weeks has been solved.

The Patriot Ledger reports that a water sample test conducted by the Massachusetts Water Resources Authority earlier this month detected a type of brown algae that gives off a rotten egg smell from the hydrogen sulfide gas emitted when it dries in the sunlight.

State officials say it’s the first time the algae, known as Pilayella littoralis, has been detected in Quincy. It’s been a problem in Nahant for years.

Residents of an elderly apartment complex in the city’s Squantum neighborhood have been complaining for several weeks about the odor. One resident called it “unbearable.”

The state says there are no documented detrimental health effects associated with the algae.