# Loop inside loop - find latest loop value

**URL:** https://discourse.processing.org/t/loop-inside-loop-find-latest-loop-value/36945
**Category:** Beginners
**Created:** [May 18, 2022, 7:20pm UTC](https://discourse.processing.org/t/loop-inside-loop-find-latest-loop-value/36945 "2022-05-18T19:20:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Erif](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/erif/32/15932_2.png) [@Erif](https://discourse.processing.org/u/Erif)
#### Post date: [May 18, 2022, 7:20pm UTC](https://discourse.processing.org/t/loop-inside-loop-find-latest-loop-value/36945/1 "2022-05-18T19:20:26Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

Hi there, I still have some issues with nested loops conceptually.  
Is there a way to know what would be the last value of ‘angle’ before the loop repeats itself? Is it 359? Asking this as the output I get is a rotating figure BUT at a certain point in time it doesn’t rotate anymore, so trying to obtain that final static output without the double loop if possible.  
PS: If I remove the 2nd loop and substitute ‘angle’ by 359 I don’t obtain the same result. Thanks.

```auto
float angle = 0;
for(int i = 1; i < 200; i++) {
   rotate(radians(angle));
     for(int j = 1; j < 360; j++) {
       angle += 1;
     }

```

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [May 18, 2022, 8:27pm UTC](https://discourse.processing.org/t/loop-inside-loop-find-latest-loop-value/36945/2 "2022-05-18T20:27:31Z")

</div>

Hello @Erif ,

Put some _print()_ or _println()_ statements in there to see the values:

```auto
float angle = 0;
for (int i = 1; i < 5; i++) 
  {
  //println(i, angle);  
  for (int j = 1; j < 5; j++) 
    {
    angle += 1;
    println(i, j, angle);
    } 
  }

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/2/32475cd0c24fdfbb6ab7a19e5b289e5d086399bc.png)

`:)`

---

<div class="post-metadata">

### Author: ![Erif](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/erif/32/15932_2.png) [@Erif](https://discourse.processing.org/u/Erif)
#### Post date: [May 18, 2022, 8:40pm UTC](https://discourse.processing.org/t/loop-inside-loop-find-latest-loop-value/36945/3 "2022-05-18T20:40:47Z")

</div>

Ah yeah cool!! I had put println(i) but didn’t occur to me to add j and angle haha. Thanks!
