def recursiveSum(n)
    return 0 if n == 0
    n + recursiveSum(n-1)
end

puts "==============Sum of N natural numbers==============="
num = recursiveSum(10)
puts num

puts "==============Ascending ordered numbers==============="
def increasing(n)
    return if n < 1
    puts n
    increasing(n-1)
end

increasing(10)

puts "==============Descending ordered numbers==============="
def decreasing(n)
    return if n < 1
    decreasing(n-1)
    puts n
end

decreasing(10)

puts "==============Nth Fibonacci numbers==============="

def fibonacci(n)
    return n if n <= 1
    fibonacci(n-1) + fibonacci(n-2)
end

puts fibonacci(10)

puts "==============Power of recursion==============="

# Problem - https://[Log in to view URL]

def poe(n,m)
  return 1 if m < 1
  n * poe(n, m-1)
end

p poe(5, 9)

puts "==============Print 1 to N numbers==============="

# Problem - https://[Log in to view URL]

def print_nos(n)
  return if n < 1
  print_nos(n - 1)
  print "#{n} "
end

print_nos(20)

print "\n"

puts "==============Count of digits==============="

# Problem - https://[Log in to view URL]

def count_of_digits(n)
  return n if n < 10
  1 + count_of_digits(n / 10)
end

p count_of_digits(12345678987654321)

puts "==============Sum of digits==============="

# Problem - https://[Log in to view URL]

def sum_of_digits(n)
	if n < 10
		return n
	end
	return n%10 + sum_of_digits(n/10)
end

p sum_of_digits(12345)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: