Sunday, 29 July 2012

Lua: Calculate a prime number list

Lua is an extension language.

This script calculates a prime number list starting with smaller ones.

To run this script you need to install lua language: (e.g: in Debian or Ubuntu)
$ sudo aptitude install lua

Current version(when this article was written) is 5.1:
$ sudo aptitude install lua5.1

After installing it, lua interpreter could be found in /usr/bin/lua.

Then you copy this script in a file, e.g: primes.lua and exec:

$ lua primes.lua 20 # it will calculate first twenty prime numbers.

or give execution permissions to the file:
$ chmod a+x primes.lua
$ ./primes.lua 20