Hi, I'm having a difficult time printing the product of the odd integers from 1 - 15. When I run it the program prints "1 2 2 2 2 2 etc." I don't see what I'm missing or why it won't print what I want. Did I add something I shouldn't have?
package javaapplication11;
/**
*
* @author Day
*/
public class test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int p = 1;
for (int i = 1; i <= 15; i++)
{
if(p % 2 == 1)
{
p = p * i;
}
System.out.printf("%5d",p);
}
}
}
thanks.