# Maple function for while browsing

• In the following the algorithm inside the for while loop runs until the condition the A * B = 0 is met. When the condition is met the for statement finishes and algorithm returns the values of A and B as a list.

#Algorithm

$res = maple(" randomize(): gen := rand(0 .. 5): det := 1: for i while det <> 0 do A := gen(); B := gen(); det := A*B end do: [i,A,B] ");$A=switch(1,$res);$B=switch(2,\$res);


In the output below you can see the first value of the list is the variable i, which is the number of times the loop ran until it succeeded.