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 […]

Read more

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, […]

Read more

Use, Host and Download Google fonts on your own website

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 […]

Read more

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 […]

Read more

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?

Read more

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 […]

Read more

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 == […]

Read more

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.

Read more

Project Euler – Problem 3 – Largest Prime Factor

Problem 3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?

Read more

Simple Script Prime Numbers

I was working with the Project Euler #3 and i need to check if a number is a prime, so i decided to post the script for checking if a number is a prime in here first. The first number on the Euler problem 3 is 13195. Checking […]

Read more
Page 1 of 212