## The Practice of Perl

Well.. a sugestive title for an post, but I decide for this title because of Perl is one of my prefer programming languages, my “swiss army knife”… and dont first time that I using perl for solving my problem… ehehehhehehehhee…

But why I talking about perl here??? Because of one problem, for more exactly, the problem 5 of Project Euler (http://projecteuler.net/), a site with mathematical problems that resolve with the use of algorithms. The problem 5 it follows below:

**2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.**

**What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?**

I trying resolve this using C, but I dont have an simple compiler in my work machine,because in my opinion, Visual C is much complex for this task… (some of my friends dont think it…)

But I think… I have perl interpretor in my machine and write this program in perl dont much harder and I starting the port of C for Perl and write this piece of code for solving my problem:

for ( my $n = 20; 1; $n++ ) {

for ( 1..20 ) {

if ( $n % $_ ) {

last;

}

if ( $_ == 20 ) {

die $n;

}

}

}

Well… is an idiot program, extremaly simple but I have the answer of problem with this… dont consider the execution time, “only” 20 min of the pure brute force for answering the problem… ehehhehehehehehhehe…

And perl with your practical syntax save my world one more time!!!! š

In Play: Gorguts – The Erosion of Sanity – 04: Orphans of Sickness

I would like to see a continuation of the topic

MaximusDecember 20, 2007 at 8:55 am