/** * 不使用递归方式计算斐波拉契数列 * @paramindex 计算的项数*/publicstaticlongfibonacciNoUseRecursion(int index){if(index <=1){return index;}longfirst=0;longsecond=1;for(inti=0; i < index -1;i++){ second = first + second; first = second - first;}return second;}
public static void test1(int n) {
if (n > 10) {
System.out.println("n > 10");
} else if (n > 5) {
System.out.println("n > 5");
} else {
System.out.println("n <= 5");
}
for (int i = 0; i < 4; i++) {
System.out.println("test");
}
}
public static void test2(int n) {
for (int i = 0; i < n; i++) {
System.out.println("test");
}
}
public static void test3(int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
System.out.println("test");
}
}
}
public static void test4(int n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < 15; j++) {
System.out.println("test");
}
}
}
public static void test5(int n) {
while ((n = n / 2) > 0) {
System.out.println("test");
}
}
public static void test6(int n) {
while ((n = n / 5) > 0) {
System.out.println("test");
}
}
public static void test7(int n) {
for (int i = 1; i < n; i = i * 2) {
for (int j = 0; j < n; j++) {
System.out.println("test");
}
}
}
public static void test8(int n) {
int a = 10;
int b = 20;
int c = a + b;
int[] array = new int[n];
for (int i = 0; i < array.length; i++) {
System.out.println(array[i] + c);
}
}