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.
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.
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.
More Hacker Rank Problem & Solutions >>