# Archive for the Programming Category

## Project Euler – Problem 6 – Sum square difference

Problem 6:  The sum of the squares of the first ten natural numbers is, 12 + 22 + … + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + … + 10)2 = 552 = 3025 Hence […]

## Setting radio button to checked with jQuery

Lately I’ve been having some difficulties in setting the radio button values the way it should via jquery on load. i have been setting radio buttons from before and it seems something just wasn’t right on this instance. here is my UI. my HTML: (i am using bootstrap, […]

Update: I have found a much easier way to download and use google fonts on your local computer or use it on a local area network website. 1. you will need to select the font you wish to download from the google fonts site 2. go to […]

## Hardcoding codeigniter’s base_url into your javascript file

Its so easy and straight forward with hard coding base_url into our scripts but as your project grows and as you upload your projects into the production server then edit it is a bit frustrating. There must be a better way to handle these base_url automatically into […]

## Project Euler Problem 5 – Smallest Multiple

Problem 5: 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 positive number that is evenly divisible by all of the numbers from 1 to 20?

## Least Common Multiple in PHP

LCM(a,b) is the smallest integer divisible to both a and b from wikipedia. It can actually be simplified using prime factorization which denotes from wikipedia as: The unique factorization theorem says that every positive integer greater than 1 can be written in only one way as a […]

## Greatest Common Divisor in PHP

The greatest common divisor is defined in wikipedia as gcd(a,0) = a gcd(a,b) = gcd(a-b,b) , if a>b gcd(a,b) = gcd(a,b-a) , if b>a   Converting this to php code we get: // http://en.wikipedia.org/wiki/Greatest_common_divisor // gcd(a,0) = a // gcd(a,b) = gcd(b,a%b) function gcd(\$a,\$b){ return (\$b == […]

## Project Euler Problem 4 – Largest Palindrome Product

Problem 4: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers.