How would I write a program in Perl that would determine if a command line argument is a prime number or not?

1 Answer

Relevance
  • BigRez
    Lv 6
    1 decade ago
    Favorite Answer

    Write a small loop that checks the parameter for any remainder of all odd numbers lower than itself except for one.

    Something like (pseudocode)

    for loopctr in 3.. parameter step 2

    if parameter % loopctr = 0

    it's not a prime

    end loop

Still have questions? Get your answers by asking now.