Here is a lonk to a nice article about the existence of the cooperation between Bowie and Lennon for "Fame"
"John was hanging out. It was one of those hanging-out sessions so much a part of the '70s," Bowie told the News. "He said 'Hey, why don't we do something?' I said 'OK, you're on.' Then I (thought) 'Oh (damn), what do we do? How do you write something with a Beatle?'"
Bowie guitarist Carlos Alomar had come up with a riff they'd been doing in a cover of the old '50s Flares tune, Foot Stomping.
"We immediately started doing that. John was just playing along with it, and every now and again he'd go 'AYYMM!!' And I said 'I got it, I got it!' And I just put an F in front of it Fame! We were off and running from there."
Lennon wrote the chords, Alomar the roaring guitar line and Bowie filled in the lyrics and the lower guitar parts.
"I really wish, obviously, in hindsight that we'd done more work together. It was such a joy being in the studio with him. I wonder what we would have done," he said. "But we were having too much of a laugh. Most of the time we spent together was pure stupidity. There wasn't much work going on at all, as you can imagine."