User blog:VoidSansXD/My attempt at not creating a recursive function

JN indicates the amount of apples John has. Once John has the same amount of apples as he's eaten, you have to stop the function. John eats one apple every time he reaches a prime number. The number at the end is the amount of times you have to add or subtract one.

Up to J6
J2: John has 2 apples. That's a prime, so John has 1 apple, and 1 apple eaten. and only had to do it once. Therefore, J2 = 1.

J3: Let's say John has three apples now. Well, 3 is a prime, so he eats one, and has 2 apples now, and has eaten one. Since two is ALSO a prime, John has to eat another one. Now John has 1 apple, and has eaten 2. We won't count one as a prime number, so now John has to get another apple. Now John has eaten 2 apples, and HAS 2 apples. The amount of times he added and subtracted, are 3 times. Therefore, J3 = 3.

J4:  4+1, 5-1, 4+1, 5-1, 4+1, 5-1, 4+1, 5-1. The amount of entries is 8, therefore, J4 = 8

J5:  5-1, 4+1, 5-1, 4+1, 5-1, 4+1, 5-1. The amount of entries is 8, therefore, J5 = 7

J6:  '''6+1, 7-1,  6+1, 7-1, 6+1, 7-1, 6+1, 7-1, 6+1, 7-1, 6+1, 7-1. The amount of entrie is 12, therefore, J6 = 12'''

Sorry if this function is bad, it's my first nonrecursive function ;-;