Most voted "mathematics" questions
Mathematics is the science of logical and abstract reasoning that studies quantities, structure, measurements, spaces and variations. Any math questions on this site should be related to programming.
Learn more…369 questions
Sort by count of

174
votes6
answers5796
viewsHow is computer randomization generated?
Doubts How computer randomization is done? What algorithm or mathematical basis does the computer use to generate those numbers? For example: No Javascript utilizo o Math.random() it returns me…

87
votes3
answers21628
viewsDefinition of the "Big O" notation
In discussions about algorithmic performance, the use of notation is very common Big O: O(1), O(n), O(n2) It is easy to find the scientific definition of this notation and it is easy to find some…

62
votes4
answers2243
viewsHow do I implement wind in a trajectory equation?
Has a game of tank 2D, using the Unityengine in C#, in which it is played on the side of the screen, seeing only the sides of the tanks, in which has the green and red tank. The green need to shoot…

56
votes4
answers3125
viewsPrecise math division
In Windows calculator: 9/3,0001 = 2,999... In my program: 9/3,0001 = 3; I would like to get that level of accuracy using C. Watch excerpts from my program: double op(double num1, double num2, char…

47
votes8
answers4052
viewsHow to generate 200,000 primes as fast as possible in Python?
Heed: I’m not looking for readymade pieces of code. I just want someone to help me think about in some way to generate these 200,000 primes as efficiently as possible, in Python. I’m working on it…

46
votes5
answers9524
viewsReceive an expression and calculate in C
I am developing this program that should receive an expression from the user and do the calculation. Ex: Insert an expression 3*51 14 My problem is how to handle the usersent expression. I was…

39
votes3
answers6437
viewsInaccurate result in broken numbers calculation
Problem Test there in the consoles of your browsers: 1067.111000 = 67.1099999999999 The right thing would be 67.11 Could someone explain this to me? And how do I fix it?…

35
votes8
answers4394
viewsHow to identify "Capicua" numbers that have 5 digits?
According to this definition of Priberam.pt, a Picua number is: Number also read from right to left or vice versa and to which good luck is attributed. Following this reasoning, Picua would be…

32
votes5
answers1927
viewsWhy is multiplication faster than division?
Bit brushing question, but I was reading an article about javascript in which says that division is slower than multiplications. And for example, I would recommend changing the code below : var…
javascript mathematics performance optimizing characteristiclanguageasked 10 years, 4 months ago Guilherme de Jesus Santos 6,566 
26
votes2
answers2114
viewsWhat is an asymptote?
In a reply came the term asymptotic. In comment came a definition. I think it would be to have a more complete definition here. But the focus of the question is even simpler: In Portuguese clear,…

24
votes3
answers2716
viewsHow to prove the asymptotic order of an algorithm?
Considering an algorithm like the one below: function somaMatriz(matA, size) { let soma = 0; // 1 for(let i = 0; i < size; i++){ // n + 1 for(let j = 0; j < size; j++){ // n(n + 1) soma +=…

23
votes1
answer1194
viewsRegular expression to recognize language: words that do not contain "bbab"
The @LINQ challenged me to write a regular expression to recognize the following language L: I was able to assemble, on this premise, the following finite state machine: the Miguel Angelo detected a…
regex mathematics computertheory automata formallanguagesasked 6 years, 10 months ago Jefferson Quesado 22,370 
23
votes2
answers1397
viewsHow to calculate the value of a polynomial function at an arbitrary point?
I need to calculate the value of a polynomial function of arbitrary grade in arbitrary values of the realm. I would like to know how to do it in a way that is not naive when doing the floating point…

21
votes1
answer778
viewsWhat are errorcorrecting codes?
What they are and how they work errorcorrecting codes (errorcorrecting code)? I’ve seen this concept for example in QR Code (where partially damaged and/or imperfectly captured code is still…

19
votes3
answers1826
viewsHow to calculate PI with "n" decimal places in Javascript?
Using the object Math of Javascript, I can return an PI value with fixed decimal places, example: Math.PI //3.141592653589793 But in case I need (yes, very unusual) calculate the same with more…

18
votes1
answer27783
viewsWhat’s the difference between Modus Ponens and Modus Tollens?
Again in the study of mathematical logic, how to differentiate a proposition modus Ponens of a modus Tollens?

18
votes8
answers2184
viewsHow to know all possible combinations of 0 and 1 in Java?
What possible combinations can I get only with numbers 0 and 1 using 5 digits (digits)? For example: 00000 00001 00011 ... 11111. I wanted to keep all the combinations, but I don’t know how to find…

16
votes4
answers4212
viewsHow do I start the next ten?
How can I round a number to the nearest ten in Javascript? For example: The user type 11, then round to 20; the user type 11.5, round to 20; and so on.

15
votes2
answers1239
viewsWhat is the difference between *var++ and *var += 1?
I’m writing a feature with the signature: int increment(int *val). My intention is to receive an entire pointer, increase its value in 1 and return that value. The body of my function was as…

15
votes2
answers6108
viewsRandom draw, but with different odds
I am implementing a system where the user clicks on a button and a draw with balls of different colors occurs, but for each color there is a probability: He has a 30% chance of catching a blue ball…

15
votes1
answer229
viewsIs a finite state machine capable of detecting the primality of a number?
I recently saw a publishing how they taught Perl to recognize a prime number using regular expressions. The regular expression in question is: /^1?$^(11+?)\1+$/ The only requirement of this regular…
regex mathematics computertheory automata formallanguagesasked 4 years, 5 months ago Jefferson Quesado 22,370 
14
votes3
answers30199
viewsHow do I round numbers to the nearest integer?
I have numbers double as double a = 0.4, b = 0.5; How do I round it up?

14
votes2
answers3574
viewsWhy is set theory so important to computation?
For computer theory, formal languages among other areas as well as for programming (development) set theory is always present, I know that mathematics is strongly linked to computation, but why do…

14
votes6
answers6260
viewsHow to determine if a number is power 2?
I need to develop an algorithm in Visualg where I enter with a number and it tells me if it’s power of 2 or not. What strategies can I use?

14
votes1
answer1573
viewsWhy do the arrays index and other sequences start at zero?
Why the array does not start with 1? There is some technical reason to have adopted 0?
c array characteristiclanguage mathematics computerscienceasked 7 years, 5 months ago Maniero 444,682 
14
votes2
answers2682
viewsIs it possible to declare Unknowns in Python to calculate constants of a Mathematical function?
I need to assemble a quadratic function Y = Ax² + bx + c from values of X and Y acquaintances. In this case, I’m trying to H(Q) = aq² + Bq + c (Gauge height as a function of flow rate). Where: H1 =…

13
votes3
answers799
viewsFloats module in PHP returns integers?
How do I get the rest of the division (operation module %) with decimal places when using a divisor or dividend float? Example: echo 5 % 3; // imprime 2 como é esperado echo 5.6 % 3; // imprime 2…

13
votes8
answers59138
viewsHow to raise a number to a power without using the Math. h library?
How can I raise a number to a power without using the library math.h? Example: potencia = x ^ 1/2; How do I do it in c++?

13
votes2
answers2440
viewsHow does Math.sqrt work in javascript?
All right, I know it returns the square root of a number. But, what numerical operations it does to bring this result?

13
votes3
answers971
viewsHow to find "Happy Numbers" within an interval?
I’m making an application where I need to find Happy Numbers within a certain range, in the case of 0 to 50, and I found this in Wikipedia: The happy numbers are defined by the following procedure.…

12
votes7
answers8546
viewsHow to implement a linear regression algorithm?
I need to implement a linear regression algorithm. Preferably that gives equal or near results to the function TENDENCY (or TREND) excel. I’ve found a lot of material that tries to explain the whole…

12
votes3
answers4953
viewsHow is the module math calculation (%) done in Javascript?
I am trying to use "reverse engineering" to understand what is the calculation done by the module (%), but I’m not getting it and I wanted to understand and clarify, to make this part clear, before…

11
votes2
answers2189
viewsHow to calculate the determinant of a javascript matrix?
Ex.: det([1, 2, 3], [3, 3, 1], [1, 2, 3]) // retorna 22 Ex.: det([1, 2], [2, 5]) // retorna 1 Ex.: det([8]) // retorna 8

11
votes3
answers10308
viewsHow to calculate direct treasure custody fee
Consider the following investment: Capital inicial (C) = 1000,00 reais Juros (J) = 12% ao ano Período (n) = 8 anos Taxa de Custódia (TC) = 3% ao ano The custody fee (TC) is a fee charged annually on…

11
votes10
answers1739
viewsHow to count the zeroes to the right of a number?
I have a number, nnnnn000. I must count how many zeros on the right has that number. Test cases: 123000 zero numbers 3 102030 zero numbers 1 Open to suggestions!…

11
votes1
answer1015
viewsCalculations used to rotate an image on canvas
I have the following code below to be able to rotate an image through the canvas. function qs(selector) { return document.querySelector(selector); } function rotacionar(canvas, image, angle) {…
javascript mathematics canvas imageprocessing rotationasked 7 years, 4 months ago Wallace Maxters 102,340 
11
votes2
answers17350
viewsMinimum bit amount required to represent decimal numbers
I’m making a list of computer architecture and one of the first exercises is pretty basic: What is the minimum amount of bits required to represent in binary each of the decimal numbers without…

11
votes2
answers872
viewsProgram to simulate the anniversary paradox
In probability theory, the anniversary paradox states that given a group of 23 (or more) randomly chosen people, the chance that two people will have the same birthday date is more than 50%. For 57…

10
votes1
answer946
viewsHow to get multiple of some PHP value?
I need to do a search in the database and according to the value found within a range of values must return a specific value. For example: if you find the values 1 to 4, you must return 1, finding 5…

10
votes1
answer187
viewsHow to identify an invalid graph for operator allocation problem per machine?
Recently I was answering a question (Machine Scheduling  Graph Theory), but there was an open problem that I could not solve: Given any graph, identify if it is valid for the operator allocation…

10
votes2
answers2429
viewsWhat is the logic behind the "days * 24* 60* 60* 1000"?
Reading some things about cookies, always observe the calculation dias * 24* 60* 60* 1000 What is the logical reasoning behind this?

9
votes3
answers4910
viewsSplit result equals zero in decimals
In division 1 by 3, my program is printing the following: number e' of 0.00 What is the error in the code? #include <stdio.h> int main(){ float numero; numero = 1/3; printf("o valor do numero…

9
votes1
answer1095
viewsBiometric readers output standard on fingerprint
I would like to know the following questions from someone who has worked with a biometric fingerprint reader: The outputs of biometric readers are standard, ie a reader model A of an X mark follows…

9
votes4
answers13678
viewsRounding a decimal to a lower decimal
Using Javascript how can I round a decimal number with several decimal places to a number with two decimal places being the lowest decimal number? Example: 44,97714285714286 To 44,97 I’ve used the…

9
votes1
answer234
viewsWhat is the algorithm for distributing the paragraphs?
I am reading a specific portion of the Bible per week based on programming published on the website Jw.org. I made a javascript script that takes the paragraphs and verses of each chapter and shows…

9
votes4
answers10562
viewsPerformatively calculate the divisors of a Python number
The code I’m using is: import time def divisores(num): for i in range(1, int(num/2+1)): if num % i == 0: yield i yield num inicio = time.time() d = divisores(47587950) [print(i) for i in d]…

9
votes3
answers559
viewsWhat’s the best way to play a Loop in math?
I needed to represent and document an arithmetic algorithm in a mathematical notation, the problem is I can’t find the best way to represent a compound loop for that. Suppose we have the simple…

8
votes2
answers228
viewsData compression. Issue for Criminal Period 2012, CESPE/Unb
Hello, I have searched in several places answer to this question, but to date I did not find. The question is to be judged on Right or Wrong. Question Consider a file composed of a large number of…

8
votes3
answers12215
viewsCalculate distances between two coordinates
I am using this function below to calculate the difference between two coordinates. Through google maps is reported a difference of 2 to 3km. But the function is returning me the result…

8
votes1
answer9757
viewsHow to round up decimals to get an integer in C#?
I have the following account: var NumeroDePaginas = NumeroDeItens / 32; When I use the Math.Round It rounds both up and down. But whenever there is any decimal value I wish to return an integer…