Final answer:
Photons take from 100,000 to 1,000,000 years to travel from the Sun's core to its surface due to the random walk phenomenon within its dense interior.
Step-by-step explanation:
It takes photons approximately between 100,000 and 1,000,000 years to random walk out of the Sun. The long duration is due to the photons being repeatedly absorbed and reemitted by atoms in the Sun's dense interior, causing them to travel in a zigzagging pattern instead of a straight line. Without such interactions, photons would travel at the speed of light and reach the surface in just over 2 seconds, the same time it takes neutrinos, which do not interact with matter, to traverse through the Sun. However, due to the random walk phenomenon, the energy we observe as sunlight today originated from nuclear reactions deep within the Sun's core up to a million years ago.