<P> The different versions have different individually detailed endings (in some Scheherazade asks for a pardon, in some the king sees their children and decides not to execute his wife, in some other things happen that make the king distracted) but they all end with the king giving his wife a pardon and sparing her life . </P> <P> The narrator's standards for what constitutes a cliffhanger seem broader than in modern literature . While in many cases a story is cut off with the hero in danger of losing his life or another kind of deep trouble, in some parts of the full text Scheherazade stops her narration in the middle of an exposition of abstract philosophical principles or complex points of Islamic philosophy, and in one case during a detailed description of human anatomy according to Galen--and in all these cases turns out to be justified in her belief that the king's curiosity about the sequel would buy her another day of life . </P> <P> The history of the Nights is extremely complex and modern scholars have made many attempts to untangle the story of how the collection as it currently exists came about . Robert Irwin summarises their findings: "In the 1880s and 1890s a lot of work was done on the Nights by Zotenberg and others, in the course of which a consensus view of the history of the text emerged . Most scholars agreed that the Nights was a composite work and that the earliest tales in it came from India and Persia . At some time, probably in the early 8th century, these tales were translated into Arabic under the title Alf Layla, or' The Thousand Nights' . This collection then formed the basis of The Thousand and One Nights . The original core of stories was quite small . Then, in Iraq in the 9th or 10th century, this original core had Arab stories added to it--among them some tales about the Caliph Harun al - Rashid . Also, perhaps from the 10th century onwards, previously independent sagas and story cycles were added to the compilation (...) Then, from the 13th century onwards, a further layer of stories was added in Syria and Egypt, many of these showing a preoccupation with sex, magic or low life . In the early modern period yet more stories were added to the Egyptian collections so as to swell the bulk of the text sufficiently to bring its length up to the full 1,001 nights of storytelling promised by the book's title ." </P> <P> Devices found in Sanskrit literature such as frame stories and animal fables are seen by some scholars as lying at the root of the conception of the Nights . The motif of the wise young woman who delays and finally removes an impending danger by telling stories has been traced back to Indian sources . Indian folklore is represented in the Nights by certain animal stories, which reflect influence from ancient Sanskrit fables . The influence of the Panchatantra and Baital Pachisi is particularly notable . The Jataka Tales are a collection of 547 Buddhist stories, which are for the most part moral stories with an ethical purpose . The Tale of the Bull and the Ass and the linked Tale of the Merchant and his Wife are found in the frame stories of both the Jataka and the Nights . </P>

When was one thousand and one nights written
find me the text answering this question