O'Reilly logo

GNU Octave by Jesper Schmidt Hansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required