Ibn Tufail drew the name of the tale and most of its characters from an earlier work by Ibn Sina (Avicenna), but the plot was very different, and the book was a new and innovative work in its own right. Avicenna's story was essentially a thought experiment about the active intellect, personified by an elderly sage, instructing the narrator, who represents the human rational soul, about the nature of the universe.
The plot of Ibn Tufail's more famous Arabic novel was inspired by Avicennism, Kalam and Sufism, and was also intended as a thought experiment. Ibn Tufail's novel tells the story of an autodidactic feral child, raised by a gazelle and living alone on a desert island in the Indian Ocean. After his gazelle mother passes away when he is still a child, he dissects her body and performs an autopsy in order to find out what happened to her. The discovery that her death was due to a loss of innate heat sets him "on a road of scientific inquiry" and self-discovery.
Without contact with other human beings and solely by the exercise of his faculties, Hayy discovers ultimate truth through a systematic process of reasoned inquiry in seven phases of seven years each. Hayy ultimately comes into contact with civilization and religion when he meets a castaway named Absal. He determines that certain trappings of religion and civilization, namely imagery and dependence on material goods, are necessary for the multitude in order that they might have decent lives. However, he believes that imagery and material goods are distractions from the truth and ought to be abandoned by those whose reason recognizes that they are distractions.
Ibn Tufail's book reflects one of the main concerns of Muslim philosophers, that of reconciling philosophy with revelation. At the same time, the narrative anticipates in some ways both Robinson Crusoe and Emile, or On Education. The story of Hayy Ibn Yaqzan is also similar to the later story of Mowgli in Rudyard Kipling's The Jungle Book.

Question: How long does it take the child to find out the "ultimate truth"?
Answer: Seven years.
Alternative answer: Forty Nine years.