Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
You are given a positive integer N. Print a numerical triangle of height N – 1 like the one below:
1
22
333
4444
55555
......
Can you do it using only arithmetic operations, a single for loop and print statement? Use no more than two lines. The first line (the for statement) is already written for you. You have to complete the print statement.
Note : Using anything related to strings will give a score of 0.
A single line containing integer,N.
Print N -1 lines as explained above.
5
1
22
333
4444
for i in range(1,input()):
print i*((10**i - 1)/ 9 )
for i in range(1,int(input())): #More than 2 lines will result in 0 score. Do not leave a blank line also
print((10**i - 1) // 9 * i)
for i in xrange(input()-1):
print (i+1)*(10**(i+1)-1)//9
for i in range(1,int(input())):
print(i*(pow(10,i)//9))
In our experience, we suggest you solve this Triangle Quest Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
Triangle Quest is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get all Hacker Rank Solution
I hope this Triangle Quest Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Hacker Rank Problem & Solutions >>
Mini-Max Sum Hacker Rank Solution
String Validators Hacker Rank Solution
Text Alignment Hacker Rank solution