All pastes #536191 Raw Edit

Something

public java v1 · immutable
·published 2007-06-04 09:28 UTC
rendered paste body
/* * Problem 2: Write a program that accepts two  * numbers from the command line and prints them out. * Then use a for loop to print the next 13 numbers in * the sequence where each number is the sum of the * previous two. For example: */public class prob2 {		int number_one = 0;	int number_two = 0; 	int seq_count = 0;	String output;		public prob2(int number_one, int number_two) {		this.number_one = number_one;		this.number_two = number_two;	}		public int fib(int nr_) {		if(seq_count == 13) return 1;				seq_count++;				if(nr_ == 0)  return fib(this.number_one-1) + fib(this.number_two-2);		this.output =  output + " " + nr_;		return (fib(nr_-1) + fib(nr_-2));	}	public void fibonacci() {			System.out.println("Sequence :");			System.out.println(this.number_one+" "+this.number_two);			if(fib(0) == 1)			System.out.println(this.output);	}		public void go() {		fibonacci();	}		public static void main(String[] args) {				if(args.length < 2 || args.length > 2) {			System.out.println("Problem, you need insert two numbers");			System.exit(-1);		}		int argument_1 = Integer.parseInt(args[0]);		int argument_2 = Integer.parseInt(args[1]);		prob2 program = new prob2(argument_1, argument_2);		program.go();	}}