10 Factors


In the twelve months from March 2013 to March 2014, I programmed solutions to the problems posted on the Contest Coding blog run by Lewis Cornwall, solving 33 problems (out of 47) and achieving a position of 4th on the leaderboard (out of 23).

As that blog has now been discontinued, I’m posting here the solutions I programmed to those problems.

10 Factors

A factor of a number is a number that divides equally into that number (1, 2, 3, 4, 6, 12 are the factors of 12 for example). Find the first number to have 10 or more factors.

Solution and answer (Ten Factors.pas):

program Ten_Factors( output );
Solution and answer for problem "10 Factors" (1st December 2013) of http://ContestCoding.WordPress.com/


Solution programmed in Pascal using Metrowerks CodeWarrior IDE 2.1 (Discover Programming Edition); solution took ~1s to run on a 80MHz PowerPC 601.
  i : 0..maxint;
  number_of_factors : 2..maxint;
  k : 0..maxint;
  i := 0;
    i := i + 1;
    number_of_factors := 2; { 1 and i are factors of i. }
    for k := 2 to i div 2 do
      if i mod k = 0 then
        number_of_factors := number_of_factors + 1
  until number_of_factors >= 10;
  writeln( i )

No Responses Yet to “10 Factors”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: