7. Example

7. Example

Output generated with Examples.jl based on this source file.

This is an example source file for input to Examples.jl.

If you are reading this you are seeing the markdown output generated from the source file, here you can see the corresponding notebook output: example.ipynb

Rational numbers in Julia

Rational number in julia can be constructed with the // operator:

x = 1//3
y = 2//5
2//5

Operations with rational number returns a new rational number

x + y
11//15
x * y
2//15

Everytime a rational number is constructed, it will be simplified using the gcd function, for example 2//4 simplifies to 1//2:

2//4
1//2

and 2//4 + 2//4 simplifies to 1//1:

2//4 + 2//4
1//1