Not quite the same story but the same number...
.....the total number of grains - 18446744073709551615 - was
not only beyond the means of his granaries, but beyond the means
of the granaries of all the world. The formula for arriving at this
number 2^64 — 1 - turns up in another famous legend ....
The Tower of Brahma
This, so the legend has it, is a temple in Benaras. They say that
when the great lord Brahma created the world he put up three
diamond sticks, mounted on a brass plate, beneath the dome that
marks the centre of the world. Upon one of the sticks he placed
64 gold discs. The biggest at the bottom, all decreasing in size,
with the smallest at the top. The temple priests have the tasks
of transposing the discs from one stick to the other, using the
third as an aid. They work day and night, but must transpose only
one disc at a time and must not put a bigger disc on top of a
smaller one. When their task is complete, the legend says, the
world will disappear in a clap of thunder.
Now the total number of transpositions needed to shift the
64 discs is, again, 2^64 - 1, or 18446744073709551615. If every
transposition takes a second it will still take 500000 million years
to get the job done.
(that's taken from a book called Figuring, The Joy of Numbers, I bought it in 1977 when I was 13 and it got me interested in numbers. No wonder I couldn't quite remember the story, I read it 41 yrs ago! )