Answers for "octave endwhile if"

0

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
Posted by: Guest on January-25-2021

Browse Popular Code Answers by Language