JamesonSherman
10/4/2017 - 1:12 PM

Factoring by Two - Java

This Snippet Factors by Two and displays the multiples of two

int count = 1;
		int product = 1;
		int factor = 1;
		int nonneg = 0;
		
		System.out.println("input a non negative number");
		nonneg = input.nextInt();
		
		while (count <= nonneg)
		{
			 product = product * factor++;
			 count++;
			 
		}
		
		System.out.println(nonneg + "! = " + product);