I'm fairly certain this is from Arthur C. Clarke's short story "The Nine Billion Names of God", partly used as inspiration for 2001: A Space Odyssey.
Same thing Asimov usually did—a shower and/or stoned "what if...?" idea turned into a short story in a straightforward way—except Clarke took the extra step to, like, write actual characters and draw a setting and maybe even establish tone and mood beyond whatever the literal plot itself necessarily conveys.