Javatpoint Logo
Javatpoint Logo

F# While Loop

In F#, while loop is used to iterate program code several times. It is recommended to use while loop if you don't know number of iterations prior.

Flowchart:

FSHARP While loop 1

F# Nested While Loop

F# allows a while loop inside another while loop which is known as nested loop. The inner while loop is executed fully when outer loop is executed once.

Let's see an example of nested while loop.

Output:

1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3

F# Infinite While Loop Example

You can create infinite while loop by using true literal as test condition. It is recommended to use infinite loop safely otherwise it may cause memory overflow error or your system may halt.

Output:

Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
Ctrl+Z
 
Next TopicF# Functions




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA