How to resolve the algorithm Loops/Increment loop index within loop body step by step in the Phix programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Loops/Increment loop index within loop body step by step in the Phix programming language

Table of Contents

Problem Statement

Sometimes, one may need   (or want)   a loop which its   iterator   (the index variable)   is modified within the loop body   in addition to the normal incrementation by the   (do)   loop structure index.

Demonstrate the best way to accomplish this.

Write a loop which:

Extra credit:   because of the primes get rather large, use commas within the displayed primes to ease comprehension.

Show all output here.

Not all programming languages allow the modification of a loop's index.   If that is the case, then use whatever method that is appropriate or idiomatic for that language.   Please add a note if the loop's index isn't modifiable.

Let's start with the solution: