/* A high-gluten ramen, cut in the middle, you can get 2 noodles. If you fold 1 times in the middle, you can get 3 noodles by cutting a knife. If you fold 2 times in a row, cut a knife in the middle, you can get 5 noodles. so, 10 times in a row, cut a knife in the middle, how much noodles will get? -------------------------------------------Fold 0 times, get 2, fold 1 times, get 2 * 2-1 = 3 fold 2 times, get 3 * 2-1 = 5 Fold 3 times, get 5 * 2-1 = 9 Fold 4 times, get 9 * 2-1 = 17 Fold 5 times, get 17 * 2-1 = 33 Fold 6 times, get 33 * 2-1 = 65 Fold 7 times, get 65 * 2-1 = 129 fold 8 times, get 129 * 2-1 = 257 fold 9 times, get 25 7 * 2-1 = 513 Fold 10 times, get 513 * 2-1 = 1025*/public class Test2 {public static int F (int n) {if (n==0) return 2;return 2*f (n-1) -1;} public static void Main (string[] args) {System.out.println ("10 times in Fold" +test2.f (10) + "root Slim");}}
Java Programming: Cutting noodles