Meet Google Drive - One place for all your files

1.) a)

// Sequence: 3, 5, 7, 9, 11
public static int calcTerm(int n){
        //where n is the term number
        if(n==1){
            return 3;
        }

        else {
            return calcTerm(n-1)+2;
        }
    }

1.) b)

//Sequence: 2, 4, 7, 11, 16
public static int calcTerm(int n){
        //where n is the term number
        if(n==1){
            return 2;
        }

        else {
            return calcTerm(n-1)+n;
        }
    }

1.) c)

//Sequence: 1, 2, 3, 5, 8
public static int calcTerm(int n){
        //where n is the term number
        if(n==1){
            return 1;
        }
        else if(n==2) {
        	return 2;
        }
        
        else {
        	return calcTerm(n-1) + calcTerm(n-2);
        }

        
    }

2.) a)

//Sequence: 10, 13, 16, 19, 22
public static int calcTerm(int n){
        //where n is the term number
        if(n==1){
            return 10;
        }
        
        else {
        	return calcTerm(n-1) + 3;
        }
        
    }

2.) b)

//Sequence: 5, 15, 45, 135, 405
public static int calcTerm(int n){
        //where n is the term number
        if(n==1){
            return 5;
        }
        
        else {
        	return calcTerm(n-1)*3;
        }
        
    }

2.) c)

//Sequence: 256, 64, 16, 4, 1
public static int calcTerm(int n){
        //where n is the term number
        if(n==1){
            return 256;
        }
        
        else {
        	return calcTerm(n-1)/4;
        }
        
    }

3.)

public static int fibonacci(int n){
        //where n is the term number
        if(n<=1){
            return n;
        }
        
        else {
        	return fibonacci(n-1)+fibonacci(n-2);
        }
        
	    }

4.)

public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		
		System.out.println("Enter a number you would like to find the factorial of:");
		int num = input.nextInt();
        System.out.println(factorial(num));
    }

    public static int factorial(int n){
        //where n is the term number
        if(n<=1){
            return 1;
        }
        
        else {
        	return factorial(n-1)*n;
        }
        
    }