Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5765 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4993 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1272 |

@bt8816103042 | 739 |

@rohitanand | 495 |

@codeantik | 479 |

@shalinibhataniya1097 | 472 |

@amrutakashikar2 | 464 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@shivanandp12345678910 | 453 |

@akashkale117 | 453 |

@SherlockHolmes3 | 447 |

Complete Leaderboard |

Given a number N.Check whether it is a triangular number or not.

Note: A number is termed as a triangular number if we can represent it in the form of a triangular grid of points such that the points form an equilateral triangle and each row contains as many points as the row number, i.e., the first row has one point, the second row has two points, the third row has three points and so on.

The starting triangular numbers are 1, 3 (1+2), 6 (1+2+3), 10 (1+2+3+4).

**Example 1:**

**Input:**
N=55
**Output:**
1
**Explanation:**
55 is a triangular number.
It can be represented in 10 rows.

**Example 2:**

**Input:**
N=56
**Output:**
0
**Explanation:**
56 is not a triangular number.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **isTriangular() **that takes a number N as input parameter and returns 1 if it is a triangular number. Otherwise, it returns 0.

**Expected Time complexity:**O(LogN)

**Expected Auxillary Space:**O(1)

**Constraints:**

1<=N<=10^{6}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Triangular Number

...