Yuan has two pieces of yarn, one 4 feet long and the other 18 feet long. For a craft project, he wants to cut them up to produce many pieces of yarn that are all of the same length, with no yarn left over. What is the greatest length, in feet, that he can make them?