math
HackerRank - Minimum Height Triangle
· ☕ 2 min read · ✍️ devoalda
Introduction Given integers b and a, find the smallest integer h, such that there exists a triangle of height h, base b, having an area of at least a. Example Input Output 1 2 3 4 # Input: 2 2 # Output: 2 {: file="Input and Output” } Explanation: The task is to find the height of the triangle having base b = 2 and area a = 2.

The Factorial Function
· ☕ 2 min read · ✍️ devoalda
The Factorial Function The factorial function is a mathematical function that takes a non-negative integer n and returns the product of all positive integers less than or equal to n. The factorial function is denoted by n!. This is a reference page for the factorial function, written in C and Python. Background The first 10 factorials are: n n! 0 1 1 1 2 2 3 6 4 24 5 120 6 720 7 5040 8 40320 9 362880 10 3628800 Where $n!

HackerRank - Project Euler #1: Multiples of 3 and 5
· ☕ 2 min read · ✍️ devoalda
Introduction If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below N. Input and Output Format 1 2 3 4 5 6 7 # Input: 2 10 100 # Output: 23 2318 {: file="Input and Output” }

HackerRank - Handshake
· ☕ 1 min read · ✍️ devoalda
Introduction At the annual meeting of Board of Directors of Acme Inc. If everyone attending shakes hands exactly one time with every other attendee, how many handshakes are there? Input and Output Format 1 2 3 4 5 6 7 # Input: 2 1 2 # Output: 0 1 {: file="Input and Output” } Process This is a math challenge. So using the primitive way of counting, I counted the number of handshakes for each number of attendees, I came up with this: