A Pythonian Look at the Family Tree Conundrum

vegaseat vegaseat is offline Offline Jul 24th, 2005, 12:25 pm |
0
The other day I was looking at my family tree. There are my parents Antonio and Lucy Vegaseat, then my grandparents Alfonso and Ludmilla Vegaseat on my father's side and Roland and Helga Gruenspan on my mother's side. Then come my great grandparents, by now there are eight of those. It was time for a small Python program to figure out how many great great great ... grandparents I had.
Quick reply to this message  
Python Syntax
  1. # The family tree conundrum ...
  2. # you have two parents, your parents each have two parents, that makes it
  3. # four grandparents for you, then there must be eight great grandparents
  4. # and so on. A light hearted look at a serious problem.
  5. # tested with Python24 vegaseat 24jul2005
  6.  
  7. generations = 3
  8. number_of_parents = 2 ** generations
  9. print "after 3 generation we have %d great grandparents" % number_of_parents
  10.  
  11. print
  12.  
  13. # going back 40 generations
  14. for generations in range(4, 41):
  15. number_of_parents = 2 ** generations
  16. print "In %d generation we have %d (g)parents" % (generations, number_of_parents)
  17.  
  18. print
  19.  
  20. print """Going back in your family tree for 40 generations, or around a thousand years,
  21. there should be over one trillion great-great-great-...-grandparents you could
  22. lay claim to being related with.
  23.  
  24. Hmmm, that alone is more people then ever lived! We demand an explanation from
  25. our government!"""
0
bumsfeld bumsfeld is offline Offline | Aug 1st, 2005
I do not know Python much, but I was taught that you start with Adam and Eve, not one trillion old people!
 
0
vegaseat vegaseat is offline Offline | Aug 20th, 2005
Wouldn't that be a lot of incest?
 
 

Message:


Similar Threads
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC