Skip to content

My Ruby venture …..

August 16, 2012

def factorial(n)
if n==0
return 1
else
n * factorial(n-1)
end
end
p factorial(0)
p factorial(20)

 

def StringMan(n, m)

return n * m

end
p StringMan(“Jagan”, 10)
p StringMan(20,30)

 

def isPalindrome?(string)
str=string.downcase;
str=str.gsub(/[^a-z]/,”);
return str == str.reverse;
end

p isPalindrome?(‘Jagan’), “\n”;

 

class HelloWorld
def doHello()
puts “Hello World”
end
end

HelloWorld.new().doHello()

Advertisements
No comments yet

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

%d bloggers like this: