Learning JavaScript through Problem Solving.

Posted: November 21, 2010 in JavaScript
Tags: ,
 

myMath = {
//Calculate Factorial
  fact : function ( n ) {
   if ( n === 0 ) {
    return 1;
   } else {
   return n*myMath.fact(n-1);
  }
}
//Write the sequence of Fibonacci number
,fibo : function ( n ) {
    f = [];f[0]=0;f[1]=1;
    for(i=0;i
        if(i>1) {
     f.push( f[i-1] + f[i-2] ); 
 }
    } 
    return (f.join());
   }
}
//Add all the natural numbers below one thousand that are multiples of 3 or 5.
Advertisements
Comments
  1. Monex Scam says:

    Furthermore the prime numbers have several properties that the number 1 lacks such as the relationship of the number to its corresponding value of or the sum of divisors function. The prime-counting function n is defined as the number of primes up to n. The second equality is a consequence of the fundamental theorem of arithmetics and shows that the zeta function is deeply connected with prime numbers.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s