How do I generate the first 12 numbers in the sequence 1, 1, 1, 2, 2, 3, 4, 5, 7, 9 using a while loop? : <p>I have figured out the formula to work the sequence out which is the use the each number in the sequence uses the previous previous previous number + the previous previous number for example to get the number 4 you use the previous x3 number which is the first 2 in the sequence plus the previous x2 number which is the second 2 in the sequence. I understand that I have to use 4 variables and then swap the number accordingly in the loop but i cant quite figure out how to do so.
Here is what I have so far.</p>

<pre><code>    System.out.print("Loop for the first 12 terms of sequence 1, 1, 1, 2, 2, 3, 4, 5, 7, 9\n");
            int p0, p1, p2, p3, c;// c in control p is num is sequence.
            c=0;
            p0=1;
            p1=1;
            p2=1;
            p3=p0+p1;
            while(c&lt;=12){
                System.out.print(p0+","+p1+","+p2+","+p3+",");
                c++;
            }
</code></pre>

<p>which just gives me the first 4 numbers of the sequence 12 times. Do I have to use an entirely different while loop for the next numbers or can I do it in the same loop?
any help appreciated. Thank you.</p>
