Statements

In the previous section, we learned how to write a very simple script and we saw that a script is just a sequence of commands. In this section, you will learn how to use statements in order to control the behaviour of a script. This enables you to code scripts that can perform different and much more complicated tasks.

Prime numbers

We will discuss the different type of statements: if, for, while, and so on by evaluating whether a number is a prime number or not. As you know, a prime number (or just a prime) x is a natural positive number that has exactly two divisors—1 and itself. Adivisor y is a natural positive number larger than 1 such that the division x/y has no remainder. From the definition of a prime, we may write a simple program ...

Get GNU Octave now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.