octave endwhile code example
Example 1: if in octave
if (condition)
then-body
endif
Example 2: octave endwhile if
The break statement jumps out of the innermost while, do-until, or for loop that encloses it.
The break statement may only be used within the body of a loop.
num = 103;
div = 2;
while (div*div <= num)
if (rem (num, div) == 0)
break;
endif
div++;
endwhile
if (rem (num, div) == 0)
printf ("Smallest divisor of %d is %d\n", num, div)
else
printf ("%d is prime\n", num);
endif