Last active
August 29, 2015 14:08
-
-
Save sai43/32ebfcc42d21bbcff563 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
* Method should accept two parameters. First parameter is first number to display, second parameter should be number of rows to be printed. | |
* Any programming language is fine. | |
* Sample: printseries(7,4) | |
* Output should be: | |
* 7 | |
* 14 15 | |
* 28 29 30 31 | |
* 56 57 58 59 60 61 62 63 | |
=end | |
class PrintSeries | |
tp = TracePoint.new(:line, :call, :return) do |tp| | |
p tp | |
end | |
# tp.enable | |
def ps(firstnum,rownum) | |
i = 0 | |
current_row = 0 | |
while current_row < rownum | |
if i == 0 | |
print firstnum | |
i += 1 | |
else | |
i = i * 2 | |
temp = firstnum * i | |
print temp | |
j = 0 | |
while j < (i-1) | |
temp = temp + 1 | |
print " #{temp}" | |
j += 1 | |
end #inner while close | |
end # if close | |
puts "" | |
current_row += 1 | |
end # main while close | |
tp.disable | |
end #ps close | |
end #class close | |
ob = PrintSeries.new | |
puts "Enter First Number : \t" | |
firstnum = gets.to_i | |
puts "Enter Row Number : \t" | |
rownum = gets.to_i | |
puts "Pascal double series is \n" | |
puts ob.ps(firstnum,rownum) | |
puts "Have a nice time..........!!!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment