#
# primes.jako
#
# A simple program to print out the primes up to 100.
#
# Based on a Parrot assembly example by Leon Brocard <acme@astray.com>
#
# Copyright (C) 2001-2005, The Perl Foundation.
# This program is free software. It is subject to the same
# license as the Parrot interpreter.
#
# $Id: primes.jako 12840 2006-05-30 15:08:05Z coke $
#

use sys;

const int n = 100;

var   int i =   2;

sys::print("Algorithm P (Naiive primality test)\n");
sys::print("  Printing primes up to $n...\n");

NUMBER: while (i <= n) {
  var int m;
  var int j = 2;

  m = i / 2;

  FACTOR: while (j <= m) {
    var int x;

    x = i % j;

    next NUMBER if (x == 0);

    j++;
  }

  sys::print("$i  ");
} continue {
  i++;
}

sys::print("\n");

