Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Triangle Quest Hacker Rank solution – Queslers

Problem :Triangle Quest Hacker Rank solution

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.


Input Format :

A single line containing integer,N.

Constraints :

  • 1 <= N <= 9

Output Format :

Print N -1 lines as explained above.


Sample Input :

5

Sample Output :

1
22
333
4444

Triangle Quest Hacker Rank solution in python 2

for i in range(1,input()):
    print i*((10**i - 1)/ 9 )

Triangle Quest Hacker Rank solution in python 3

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)

Triangle Quest Hacker Rank solution in pypy

for i in xrange(input()-1):
    print (i+1)*(10**(i+1)-1)//9

Triangle Quest Hacker Rank solution in pypy 3

for i in range(1,int(input())):
    print(i*(pow(10,i)//9))
Triangle Quest Hacker Rank Solution Review:

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

Triangle Quest Hacker Rank Solution Conclusion:

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

String validators Hacker Rank Solution

Staircase Hacker Rank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *