Source

blaise / examples / factors.bl

factors(n)
{
    vars lim, i;
    lim = sqrt(n) + 1;
    if (n == 1)
    {
        write(1);
    }
    i = 2;
    while (i <= lim)
    {
        while (mod(n, i) == 0)
        {
            write(i);
            n = n / i;
        }
        i = i + 1;
    }
    if (n > 1) {
        write(n);
    }
}

main()
{
    factors(read());
}