Re: Print Odd Multiples of 3
So you want the numbers 3, 3+6, 3+6+6 ... 3+n*6 for n >= 0 and 3+n*6 < 100? hint: a for-loop can do it.
kind regards,
Jos
Re: Print Odd Multiples of 3
You could also use the modulus operator.
Code:
if (x % 2 != 0)
{
// odd
}
Re: Print Odd Multiples of 3
Quote:
Originally Posted by
joeyvitoro
You could also use the modulus operator.
Code:
if (x % 2 != 0)
{
// odd
}
AHh I see now. multOfThree%2 produces the pattern I want for printing every other line (0,1,0,1,0), so, by making an if statement (true != true), it will print in that order.
Re: Print Odd Multiples of 3
That might have been a typo, but (true != true) will always evaluate to be false.
Re: Print Odd Multiples of 3
Quote:
Originally Posted by
joeyvitoro
You could also use the modulus operator.
Code:
if (x % 2 != 0)
{
// odd
}
Sure, why implement an efficient solution while you can hack something together?
kind regards,
Jos
Re: Print Odd Multiples of 3
Oh Jos, you always seem so mean spirited. Your method was certainly easier, and would have worked for his needs, but now he knows how to find out if any number is odd or even.
Re: Print Odd Multiples of 3
Quote:
Originally Posted by
joeyvitoro
Oh Jos, you always seem so mean spirited. Your method was certainly easier, and would have worked for his needs, but now he knows how to find out if any number is odd or even.
What is "mean spirited" about efficiency?
kind regards,
Jos
Re: Print Odd Multiples of 3
I think you're smart enough to know the difference between style and substance ;)
However, I have a thread in advanced java that I need an answer too. If you can help me out, I'll gladly accept the sarcasm that comes with it! :D
Re: Print Odd Multiples of 3
Quote:
Originally Posted by
joeyvitoro
I think you're smart enough to know the difference between style and substance ;)
However, I have a thread in advanced java that I need an answer too. If you can help me out, I'll gladly accept the sarcasm that comes with it! :D
If it's the thread about rendering cells in a JTable, I thought Fubarable answered in in his reply #5.
kind regards,
Jos