## Power sum in Ruby

It is not easy to calculate if n is 50, nad m is 9. Here Ruby comes for help. If you had already installed Ruby 1.8 or Ruby 1.9, open terminal (in Linux) type irb and press enter. Then type following (don’t type > sign) :

>sum(n,m) >return 1 if n == 1 >sum(n-1,m) + n^m if n > 1 >end

It is all, now type sum(50,9) and you will get the answer…

###### Related articles

- Ruby 1.9.3-p385 Is Available for Download (news.softpedia.com)
- Company confidential: Ruby on Rails deve (kcgrafix.wordpress.com)
- Using chruby and ruby-build to Manage Ruby Installations (gistflow.com)

## 30 Trigonemetric Problems and Equations

## Quadrilateral Problem

In quadrilateral ABCD with diagonals BD and CA, Read more…

## Fibonacci

Ruby code for Fibonacci numbers:

def fibo(n)

phi = ( Math.sqrt(5) + 1 )/2

pho = 1 - phi

if n > -1

Integer( ( phi**n - pho**n )/( Math.sqrt(5) ) )

else

Integer( ( (-1)**(n+1) )*fibo(-n) )

end

end

to be continued

###### Related articles

- Fibonacci in nature – patterns around us (dailypaul.com)
- Fibonacci (raspberry-python.blogspot.com)
- Script For Efficient High Fibonacci Number Calculation (scientificocean.wordpress.com)

## Triangle problem – finding height with given area and angles.

If the area of triangle ABC is and angles and then find a altitude of triangle which drawn from C to AB.

**HINT:** Read more…

## Range – General Information

The **range** of a set of data is the difference between the highest and lowest values in the set. For example : 21, 55, 12, 84, 32, 64. Range = 84 – 12 = 72.

The range, in the sense of the difference between the highest and lowest scores, is also called the **crude range**. When a new scale for measurement is developed, then a potential maximum or minimum will emanate from this scale. This is called the **potential (crude) range**. Of course this range should not be chosen too small, in order to avoid a ceiling effect. When the measurement is obtained, the resulting smallest or greatest observation, will provide the **observed (crude) range**.

## Median – General Information

Median is numerical value separating the higher half of a sample from the lower half. The median of some variable *x* is denoted either as or as

An example for median:

To find median of 5, 9, 2, 6, 7 firstly sort by value: 2, 5, 6, 7, 9. The middlest value is median = 6. Other method to find median = [(n+1)/2]th value. (n is the number of values. median=(5+1)/2=3. 3rd value is 6.

If number of values even:

5, 9, 2, 6, 7, 1. Sort by value: 1, 2, 5, 6, 7, 9. Median is the mean of middlest values: (5+6)/2=5.5 . Other method to find median = [(n+1)/2]th value. (n is the number of values. (6+1)/2=3.5 median is 3rd value + 0.5*|difference between 3rd and 4th value| = 5 + 0.5*(6-5) = 5.5 .