### Square Numbers

12Jul13

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 4^{th} on the leaderboard (out of 23).

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

Square NumbersA square number is a number that is the product of some integer with itself (3 * 3 = 9 for example). The base of a square number is the integer which when multiplied with itself creates that square number (3 is the base of 9, for example). Find the base of the first square number to exceed 5-digits.

**Solution and answer (Square Numbers.c):**

Includes: printDateAndTime.

/* Solution and answer for problem "Square Numbers" (12th July 2013) of http://ContestCoding.WordPress.com/ Fri Jul 12 09:00:00 2013 317 is the base of 100489, the first square number to exceed five digits. Fri Jul 12 09:00:00 2013 Solution programmed in C using Leonardo IDE 3.4.1; solution took ~1s to run on a 80MHz PowerPC 601. */ #include "printDateAndTime.h" #include <stdio.h> void main( void ) { long b = 0, sN; p_PrintDateAndTime(); do { b ++; sN = b * b; } while( sN < 99999 ); printf( "\n%ld is the base of %ld, the first square number to exceed five digits.\n\n", b, sN ); p_PrintDateAndTime(); }

Advertisements

Filed under: Uncategorized | Leave a Comment

Tags: C, computer science, computing, contest, Contest Coding, Lewis Cornwall

Advertisements

## No Responses Yet to “Square Numbers”