Math

Mathematics is the study of quantity, structure, space, and change. Any math questions on this site should be programming related.

60 votes
5 answers
479 views
How do I calculate a point on a circle’s circumference?

How can the following function be implemented in various languages? Calculate the (x,y) point on the circumfe

avatar
Joseph
0 1 0 9
asked 07 September, 2021
53 votes
9 answers
2.8K views
Is log(n!) = Θ(n·log(n))?

I am to show that log(n!) = Θ(n·log(n)). A hint was given that I should show the upper bound with nn and sh

avatar
Santiago
0 1 0 9
asked 07 September, 2021
58 votes
10 answers
2.7K views
How can I ensure that a division of integers is always rounded up?

I want to ensure that a division of integers is always rounded up if necessary. Is there a better way than thi

avatar
Robt
0 1 0 9
asked 07 September, 2021
62 votes
8 answers
1.6K views
How to scale down a range of numbers with a known min and max value

So I am trying to figure out how to take a range of numbers and scale the values down to fit a range. The rea

avatar
Keila
0 1 0 9
asked 07 September, 2021
57 votes
21 answers
604 views
Generate a random point within a circle (uniformly)

I need to generate a uniformly random point within a circle of radius R. I realize that by just picking a uni

avatar
Wilber
0 1 0 9
asked 07 September, 2021
48 votes
19 answers
458 views
Mapping two integers to one, in a unique and deterministic way

Imagine two positive integers A and B. I want to combine these two into a single integer C. There can be no

avatar
Benton
0 1 0 9
asked 07 September, 2021
66 votes
26 answers
2.8K views
Too many 'if' statements?

The following code does work how I need it to, but it's ugly, excessive or a number of other things. I&ap

avatar
Stacia
0 1 0 9
asked 07 September, 2021
53 votes
23 answers
2K views
How to determine if a list of polygon points are in clockwise order?

Having a list of points, how do I find if they are in clockwise order? For example: point[0] = (5,0) point[1

avatar
Charis
0 1 0 9
asked 07 September, 2021
63 votes
21 answers
2.4K views
Why can't decimal numbers be represented exactly in binary?

There have been several questions posted to SO about floating-point representation. For example, the decimal n

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
57 votes
7 answers
2.5K views
How can I divide two integers to get a double?

How do I divide two integers to get a double?

avatar
Santiago
0 1 0 9
asked 07 September, 2021
69 votes
7 answers
2.5K views
What is "entropy and information gain"?

I am reading this book (NLTK) and it is confusing. Entropy is defined as: Entropy is the sum of the proba

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
3K views
Calculate distance between 2 GPS coordinates

How do I calculate distance between two GPS coordinates (using latitude and longitude)?

avatar
Stacia
0 1 0 9
asked 07 September, 2021
56 votes
13 answers
741 views
Difference between Math.Floor() and Math.Truncate()

What is the difference between Math.Floor() and Math.Truncate() in .NET?

avatar
Shanita
0 1 0 9
asked 07 September, 2021
63 votes
26 answers
2.7K views
How to check if a number is a power of 2

Today I needed a simple algorithm for checking if a number is a power of 2. The algorithm needs to be: Simpl

avatar
Majorie
0 1 0 9
asked 07 September, 2021
57 votes
6 answers
2.2K views
How do I determine whether my calculation of pi is accurate?

I was trying various methods to implement a program that gives the digits of pi sequentially. I tried the Tayl

avatar
Hilario
0 1 0 9
asked 07 September, 2021
61 votes
28 answers
1.6K views
Understanding "randomness"

I can't get my head around this, which is more random? rand() OR: rand() * rand() I´m finding it a

avatar
Thurman
0 1 0 9
asked 07 September, 2021
62 votes
30 answers
1.2K views
Designing function f(f(n)) == -n

A question I got on my last interview: Design a function f, such that: f(f(n)) == -n Where n is a 3

avatar
Alphonso
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
475 views
Calculate distance between two latitude-longitude points? (Haversine formula)

How do I calculate the distance between two points specified by latitude and longitude? For clarification, I&

avatar
Forrest
0 1 0 9
asked 07 September, 2021
62 votes
30 answers
1.1K views
Easy interview question got harder: given numbers 1..100, find the missing number(s) given exactly k are missing

I had an interesting job interview experience a while back. The question started really easy: Q1: We have a b

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
439 views
Determine Whether Two Date Ranges Overlap

Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges ove

avatar
Juliane
0 1 0 9
asked 07 September, 2021