Testing express

Testing express

Monday, June 25, 2012

Recursion - A simple example in ruby

class Recursion 
   def sum_positive(n)
 
     if  n==1
        $t = 1
    else
        $t1= n.to_i + sum_positive(n-1)
    end


   end

end

s = Recursion.new
puts s.sum_positive(9)


Problem: Write a recursive Ruby function sum_positive(n) that has one parameter n that represents a positive integer. The function should return the sum of the first n positive integers. Your solution must use recursion and should not have a loop in it.
Eg;
sum_positive(5) must give

5+4+3+2+1 = 15 as output

Do you have a better solution?

Why every release is a "ThRilleR"


I bet you too might have experienced this. Thrillers have
  • Tension
  • Suspense
  • Excitement 
"A thriller is villain-driven plot, whereby he or she presents obstacles that the hero must overcome" - wikepedia

I agree with the above statement from wiki. Now you need to fit in the characters in the above statement.
Don't take it seriously ;)

I always keep thinking, why this happens?

Improper planning
Lack of motivation in team
Lot of changes
Unexpected deadlines
Unreasonable expectations
Lacking a good leader
Too much commitment
Casualness

Add on, if you can share from your experiences

"Paani da rang vekh ke, akhiyaan cho hanju rul de" = "Seeing the color of water, tears roll down my eyes" -AK