Tag: math
Question: Given an integer, write a function to determine if it is a power of three. Iterative If you divide the number (which is Power of Three) iteratively by …
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = sumRange(0, 2): 1 sumRange(2, 5): …
From this post, we know the non-deterministic approach to compute the approximation of math constant PI. The random algorithms e.g. such as xorshift need to be of high quality …
Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, …
Given a non-negative integer number, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + …