God creates the world in six days and consecrates the seventh as a day of rest. God creates the first humans Adam and Eve and all the animals in the Garden of Eden but instructs them not to eat the fruit of the tree of knowledge of good and evil. A talking serpent, portrayed as a deceptive creature or trickster, entices Eve into eating it anyway, and she entices Adam, whereupon God curses them and throws them out in the fall of man. Eve bears two sons, Cain and Abel. Cain kills Abel after God accepts Abel's offering but not Cain's. God then curses Cain. Eve bears another son, Seth, to take Abel's place.
After many generations of Adam have passed from the lines of Cain and Seth, the world becomes corrupted by the sin of man and Nephilim, and God determines to wipe out mankind. First, he instructs the righteous Noah and his family to build a huge boat and put examples of all the animals on it. Then God sends a great flood to wipe out the rest of the world. When the waters recede, God promises that he will not destroy the world a second time with water with the rainbow as the symbol of his promise. But upon seeing mankind cooperating to build a great tower city, the Tower of Babel, God divides humanity with many languages and sets them apart with confusion.
God instructs Abram to travel from his home in Mesopotamia to the land of Canaan. There, God makes a covenant with Abram, promising that his descendants shall be as numerous as the stars, but that people will suffer oppression in a foreign land for four hundred years, after which they will inherit the land "from the river of Egypt to the great river, the river Euphrates." Abram's name is changed to Abraham and that of his wife Sarai to Sarah, and circumcision of all males is instituted as the sign of the covenant. Because Sarah is old, she tells Abraham to take her Egyptian handmaiden, Hagar, as a second wife. Through Hagar, Abraham fathers Ishmael.
God resolves to destroy the cities of Sodom and Gomorrah for the sins of their people. Abraham protests and gets God to agree not to destroy the cities if 10 righteous men can be found. Angels save Abraham's nephew Lot and his family, but his wife looks back on the destruction against their command and is turned into a pillar of salt. Lot's daughters, concerned that they are fugitives who will never find husbands, get him drunk to become pregnant by him, and give birth to the ancestors of the Moabites and Ammonites.
Abraham and Sarah go to the foreign land of Gerar, pretending to be brother and sister (they are half-siblings). The King of Gerar takes Sarah for his wife, but God warns him to return her, and he obeys. God sends Sarah a son to be named Isaac, through whom the covenant will be established. At Sarah's insistence, Ishmael and his mother Hagar are driven out into the wilderness, but God saves them and promises to make Ishmael a great nation.
God tests Abraham by demanding that he sacrifice Isaac. As Abraham is about to lay the knife upon his son, God restrains him, promising him numberless descendants. On the death of Sarah, Abraham purchases Machpelah (believed to be modern Hebron) for a family tomb and sends his servant to Mesopotamia to find among his relations a wife for Isaac, and Rebekah is chosen. Other children are born to Abraham by another wife, Keturah, among whose descendants are the Midianites, and he dies in a prosperous old age and is buried in his tomb at Hebron.
Isaac's wife Rebecca gives birth to the twins Esau, father of the Edomites, and Jacob. Through deception, Jacob becomes the heir instead of Esau and gains his father's blessing. He flees to his uncle where he prospers and earns his two wives, Rachel and Leah. Jacob's name is changed to Israel, and by his wives and their handmaidens he has twelve sons, the ancestors of the twelve tribes of the Children of Israel, and a daughter, Dinah.
Joseph, Jacob's favorite son, is sold into slavery in Egypt by his jealous brothers. But Joseph prospers, after hardship, with God's guidance of interpreting Pharaoh's dream of upcoming famine. He is then reunited with his father and brothers, who don't recognize him but who plead for food. After much manipulation, he reveals himself and lets them and their households into Egypt, where Pharaoh assigns to them the land of Goshen. Jacob calls his sons to his bedside and reveals their future before he dies. Joseph lives to an old age and exhorts his brethren, if God should lead them out of the country, to take his bones with them.
Output: How many righteous men were needed to save Sodom and Gomorrah?