Dyken and Missy Franklin as the only American women to win as many as four golds in a single Olympics.

“I hit all my goals right on the nose this week,” Ledecky said. “I’m just proud to be part of that history.”

Four years ago, she seemingly came out nowhere to capture gold as a 15-year-old at the London Games. Then, after her coach moved to the West Coast, Ledecky hooked up with Bruce Gemmell and never missed a beat.

She called it “a testament to the vision that Bruce and I had three years ago when we set these goals, and we weren’t going to stop until we met them.”

As was the case in the 400 free, where she also broke her own world record, Ledecky was merely racing the clock as she powered away from the field to touch in 8 minutes, 4.79 seconds, eclipsing the mark of 8:06.68 that she set at a grand prix meet in Texas back in January.

“The goal was 8:05 or better,” she said.

Naturally, she was better.

On the medal stand, though, the emotions swept over her.

She broke down in tears, relishing her accomplishments and surely thinking about all the work she put in to make it there.

“The Olympics are the pinnacle of our sport and I have to wait another four years to have that moment and I just wanted to enjoy it,” Ledecky said. “The memories mean more than the medals to me.”

On the other side of the pool, it was a stunner in Rio: Michael Phelps was beaten.

Rather handily at that.

The most decorated athlete in Olympic history couldn’t pull off one of his patented comebacks in the 100-meter butterfly, easily held off by a swimmer a decade younger.

Twenty-one-year-old Joseph Schooling of Singapore got off to a blistering start, building a lead that not even Phelps could overcome.

After winning four gold medals at these games and looking unbeatable, Phelps finally ran out of steam in what was the final individual race of his career unless he decides to come out of retirement again.

The 31-year-old Phelps still has a chance to leave Rio with 23 golds in his career. But he’ll have to do with some help from his teammates, swimming in the butterfly leg of the 400 medley relay on the final night of swimming today.

Phelps wound up in a three-way tie for silver along with two longtime rivals, Chad le Clos of South Africa and Laszlo Cseh of Hungary. They all touched in 51.14 — a half-body length behind Schooling’s winning time of 50.39.

“A three-way tie is pretty wild,” Phelps said. “Joe is tough. Hats off to him, he swam a great race. It’s kind of special and a decent way to finish my last individual race.”

Phelps quickly swam over to congratulate Schooling, who seemed stunned by what he had done.

“It hasn’t really sunk in yet,” Schooling said. “I’m sorry if I don’t seem like I’m full of emotions right now. I don’t know what to believe, like, whether I actually did it or I’m still preparing for my race.”

Phelps, he added, is “a guy that will go down in our history books as the greatest of all time of any sport. I’m just honored and glad to have that moment and that privilege to race alongside Michael and Chad and all those guys.”

And two other Americans won gold, too. Anthony Ervin capped a remarkable personal journey with a gold in the 50 freestyle — 16 years after he won his first individual gold in the same event at the Sydney Games. And Maya DiRado knocked off the Iron Lady in the 200 backstroke, pulling off a furious rally on the final lap to beat Katinka Hosszu. Bronze went to Canada’s Hilary Caldwell.

While Ledecky, at 19, is the youngest member of the U.S. team, Ervin is the oldest at 35.

In the blink of an eye, Ervin went from one end of the pool to the other in a furious dash, edging the defending Olympic champion, Florent Manaudou of France, by a mere hundredth of a second. Another American, Nathan Adrian, took the bronze.

Ervin won his first gold at the 2000 Sydney Olympics, tying teammate Gary Hall Jr. for the top spot. Then, Ervin walked away from swimming, skipping the next two Olympics while he embarked on a journey to find his purpose in life.

Turns out, it was swimming all along.

Ervin returned to make the American team in 2012, but failed to win a medal in London. Now, improbably, he’s back on the top of the podium again.

DiRado’s upset denied Hosszu a fourth gold in Rio, and capped off a remarkable one-and-done Olympics for the American.

She’s already got a job lined up in Atlanta after the Olympics and made it clear she would be retiring no matter the results. She certainly has nothing to complain about after winning two golds, a silver and a bronze in Rio.

“This whole day has been kind of crazy because it’s all of these little last things that I’ve gotten to do, like my last warm-up with the girls at the training pool today,” DiRado said. “I wrote my parents an email this morning just saying thank you and I started bawling on my bed and then my roommates came in and comforted me. I tried to keep it all under control, but there’s been a lot of tears these last 24 hours.”