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
-
3
votes1
answer68
viewsError in Lexing a Mathematical Equation
I’m doing a C++ equation interpreter and I’m trying to show the type of the symbol. But I’m in trouble. I don’t know what’s wrong. Any constructive tips are welcome. main.cpp: #include…
-
3
votes1
answer221
viewsAlgorithm for connecting dots on a graph with curved lines
I need to develop an algorithm that connects dots in a way nonlinear, that is, with smooth curves, as in the image below: The problem is I can’t find the best solution, whether using Bezier curves,…
-
3
votes1
answer732
viewsHow to convert million units into dozens unit in R?
Suppose I have the number 80 million. Numero = 80000000 print(Numero) [1] 8e+07 Because it is a large number the R already shows me in Scientific Number, but I would like to convert that number that…
-
3
votes1
answer776
viewsWhen and where to use the terms: time complexity, space complexity?
I’m using the book Data Structures: Algorithms, Complexity Analysis and Implementations in JAVA and C/C++ as it helps with practical implementation examples. In chapter 1 there is the following…
-
3
votes1
answer108
viewsError when calculating decimal value
I need to calculate the interest value, this is the code: public async Task<decimal> CalculatesInterestAsync(decimal valorInicial, int meses, decimal juros) { var valorFinal =…
-
3
votes3
answers309
viewsHow to replace variables with NEGATIVE values with their ABSOLUTE VALUE within a date.frame in R?
First of all, what is an Absolute Value? We can say that the Absolute Value or Module is the same as the distance from a real number to zero, because the module of a real number arose from the need…
-
3
votes1
answer93
viewsCHALLENGE: Spline algorithm(s) with derivative continuity(s)
It is known that a polynomial fn:x->y=c0+x*c1+x²*c2+x³*c3+...+x^n*cn can meet the N=n+1 conditions and from n=1 there is convenience to use in Spline formulas, for example f1 can meet the…
-
2
votes3
answers89
viewsEquations in module
I need to take the height of 2 elements, where these elements can have varying heights and then find the difference between the height of them as in the example: To = 20 B = 15 |To - B| = 5 How do I…
-
2
votes3
answers787
viewsproblems to print a double number
I’m having trouble printing a double number, for example I create a double type variable, and this gets a 1/3 split, it would have to show 0.3, what I have to do to print 0.3??? public class…
-
2
votes2
answers2209
viewsTake larger existing value in a number array
By giving a function, I return an array with numerous random numbers. I need to get the largest number between this array, and for that I ended up finding the function Math.max(). The problem is…
-
2
votes2
answers471
viewsDecrease float accuracy in Javascript?
How to decrease the decimals of a float number in javascript? For example, I want 3.3333333333 become in 3.34. What is the simplest way to do this in javascript? I tried functions like Math.ceil,…
-
2
votes1
answer849
viewsHow to find the vector corresponding to the angle in 3 dimensions?
Hello, I’m doing a 3-D game and I’m having trouble doing a 3-D raycasting. In this case, I want to do it for the camera, to see if there is no object between the camera and the player. For this I…
-
2
votes1
answer623
viewsDecomposition into primes
Hello folks I’m learning C++ for Data Structure subject and there is some error in the code that is creating an infinite loop. #include <stdio.h> int fatores(int a[], int n, int *x) { int…
-
2
votes3
answers1025
viewsproblem in C with rest of the division
Develop a program that scans ten elements of an A-matrix vector type. Construct a matrix B of the same type, observing the following law of formation: if the value of the index is even, the value…
-
2
votes1
answer603
viewsVariable type for precise calculations (JAVA)
What is the best type of variable for very precise calculations ? I’ve used double and Bigdecimal and the rounding is diverging much in the end result.
-
2
votes1
answer1247
viewsC program for solving mathematical expressions using binary tree
I’m trying to build a tree that receives a completely parented mathematical expression [e.g.: ((a+b)+c)] but I think my insertion function is wrong! Will someone give me a light? typedef struct…
-
2
votes2
answers282
viewsI can’t divide with a vector element
I made a code to simulate the Monty Hall paradox, so that I can simulate 1000 times the results and write the statistics. However, I cannot divide an element of an int array by an int, every time I…
-
2
votes2
answers72
viewsComposite allocation operator
I can’t understand why he won’t perform the expression I want. Follows the code: $i = 1; $ranking = 1; $r = 0; for($i = 1; $i <=5; $i++){ $p = isset($_GET["n$i"])?$_GET["n$i"]:0; echo "$ranking °…
-
2
votes1
answer618
viewsEuclidean Division
There is a problem of Euclidean division in which the rest r cannot be greater than the b, following the theorem a = b.q + r. I made a code and got one accepted, but I found one better than mine!…
-
2
votes3
answers304
viewsWhat is the difference between the modules Math and cmath?
In Python we realize that there are the following modules: math and cmath, however I did not understand what difference between the two. See how they can be imported: import math import cmath What…
-
2
votes2
answers4251
viewsHow to make a percentage calculation on Oracle?
I can’t make a Select that can perform 1 ICI calculation on Oracle. Table VS01 Campos: PD = 001 TP = 100 reais ICI = 15 Select PD,TP,IPI, TP * IPI% AS TOTAL <<< aqui que não consigo…
-
2
votes2
answers495
viewsAdd interest per plot with Bigdecimal?
I am creating a system where I need to calculate the interest and add the installments of a loan. For this, I am using BigDecimal and I’m unable to perform the mathematical operation following the…
-
2
votes2
answers11063
viewsHow to use % in Portugol
I have the following question: Write an algorithm that calculates a worker’s salary. The user will be asked for the value of the hour worked, number of hours and the % INSS discount. At the end,…
-
2
votes1
answer2214
viewsPercentage in C
Given the following statement: Write an algorithm to show on the screen if each N number, typed user is even or odd. The algorithm should also show on the screen the sum of all even numbers, the sum…
-
2
votes1
answer512
viewsProgram that read 3 numbers with repeating structure with scanner class!
How do I make a Java algorithm that reads 3 numbers and averages? I know how to do it without repeating structure, but how to do it with repeating structure? Follow my code below, but do not have…
-
2
votes2
answers81
viewsFix incorrect module return
Mathematically speaking why it happens and how to fix the following "error" in python: >>>10.53 % 1 0.5299999999999994 I’d like to understand how the python works to obtain this value, why…
-
2
votes1
answer771
viewsFibonacci sequence
I need to do an exercise on the Fibonacci sequence: Each new term in the Fibonacci sequence is generated from the sum of the previous 2 terms. If we start with 1 and 2, the first ten numbers will…
-
2
votes1
answer213
viewsCalculations of skinfolds
Well, I don’t know if I can ask for help in calculating, more anyway, my question is this:: I need to do the calculation of skin folds, in this case the calculation of Pollok 3 folds, I researched…
-
2
votes1
answer175
viewsI calculate two-tailed in Java
How can I do the bicaudal or unicaudal calculation in Java? This calculation is done in Excel by function INVT. This Excel function is done as follows for example: =INVT(0,0455; 4,81E+01) that…
-
2
votes1
answer6600
viewsHow to calculate the use of a football team in a championship?
I’m looking to do a media calculation of a football team in a certain league, for example, my team played two matches and won one. He would have 3 points from 6 points played and a 50%. public final…
-
2
votes2
answers4669
viewsProblem with library Math. h (indefinite reference to `sqrt')
I’m having trouble compiling the code with the function sqrt() in the C language. Error: gcc exercicio_03.c /tmp/ccGVE8ez.o: na função `distancia': exercicio_03.c:(.text+0x142): referência…
-
2
votes3
answers8551
viewsGet the number of digits in a number
I was asked to make an algorithm in Python to know the number of digits in a number, there is a way to do without the manipulation of strings? def achaTamanho(x): a = str(x) if len(a) > 1: if…
-
2
votes2
answers1848
viewsTreat division by zero
I have the following function in PHP: public function teste() { $conta = "0/(0+0+0)"; eval('$result = (' . $conta . ');'); echo $result; } In this case, the formula (in example 0/(0+0+0) obviously…
-
2
votes1
answer31
viewsGet/Calular edges of a 3D object
I have the following question regarding obtaining the positions of a certain edge of a 3D object. Example, I have a track (car game) and I want to calculate, through a script C#, both sides of the…
-
2
votes1
answer266
viewsInequality in C language
Data: Brutus is 1.84m and weighs 122kg and Olivia is 1.76m and weighs 45kg. IMC = peso/(altura*altura); IMC: 18,5 a 25 -----> Saudável I want to create an algorithm that prints how much MINIMAL…
-
2
votes3
answers1436
viewsWhat is the fastest way to calculate the sequence of Fibonacci
I’m asking a question that is Fibonacci de Novo! the tests give the expected result only that gives Time limit exceeded, wanted if you have a faster way to calculate My code #include <stdio.h>…
-
2
votes1
answer2003
viewsLoop "for" counted odd number, even and average
I need to make a code that: List a number of numbers Inform if they are divisible by 3 and 5 Whether they are even or odd And then take the separate average of each (average of odd and average of…
-
2
votes2
answers255
viewsPossibility challenge in c,c++ or Matlab
I’m in need of a program that gives me the possibilities of the following equation: x*y = 1700/57 Whereas x and y are positive reals resulting from two integers ("a" and "b") different from 1 to…
-
2
votes1
answer159
viewsDistributing points evenly in a circle
I started to make a code to randomly distribute points evenly in a circle, but by generating a point located with a random theta angle between 0 and 2π and with a distance from the center of the…
-
2
votes1
answer213
viewsHow to repeat number at a maximum?
I have two whole: n and m: n: Number that will repeat in the index; m: Index maximum. What I need to do is simple, is to return a number that is <= m on the basis of n. When n is larger, it will…
-
2
votes4
answers2189
viewsSum of primes in a range in C
My problem says to add the primes in a user-given range, including the ranges if these are primes. Example: ENTRANCE: 2 and 10 EXIT: 17 I managed to do that: #include <stdio.h> int main() {…
-
2
votes1
answer2176
viewsJavascript (pure) - Find exact triangle angle according to trigonometric ratio table
I wonder if there is a way to find the exact angle of a triangle without depending on the table. In my program, I’m taking the value in radian and turning it into degrees, but the value does not…
-
2
votes3
answers249
viewsFinding an intermediate value between two variables
I’m developing an algorithm for checkers and I came across a problem, when one piece eats the other, where I need to know the position of the piece that was eaten. According to the image and the…
-
2
votes1
answer170
viewsCalculations with String in Java
I need to average some numbers I receive via JSON in the format of Strings, this calculation must return a value so that I can set it within a TextView on Android, but I’m not able to format this…
-
2
votes1
answer186
viewsDo irreversible operations exist?
In mathematics (therefore in programming) there are mathematical operations (+,-,*,/). But all the mathematical operations I know are perfectly reversible, for example, by dividing a number, I could…
-
2
votes2
answers373
viewsHow to calculate the average excluding zeroes in R?
I averaged the following values: MÉDIA = mean(c(12,20,15,0,7,0)) print(MÉDIA) [1] "9" But I need the average that doesn’t consider zeroes: MÉDIA_Sem Zeros = mean(c(12,20,15,7)) print(MÉDIA_Sem…
-
2
votes1
answer78
viewsHow to rent plots matching the total?
$meses = 3; $valor = 1000 $valor_parcela = $valor / $meses; for ($i = 1;$i <= $meses; $i++) { $date_sum_month = date('d/m/Y', strtotime("+{$i} month", strtotime($date))); array_push($boletos,…
-
2
votes3
answers3885
viewsJavascript/Jquery - Calculating days between two "DD/MM/YYYY" dates
Friends, good afternoon... next, the code below, takes two dates in a calendar, in the format of DD/MM/YYYY $('.two-calendars').on('pickmeup-change', function (evt) { var range =…
-
2
votes1
answer875
viewsHow to invert a positive number to negative and vice versa in C#?
How do I get the number typed by the user, whether positive or negative, reversed? using System; namespace POOTeste { class Program2 { static int Main(string[] args) { int numero;…
-
2
votes2
answers259
viewsCalculation of tenths of a second
I’m making a "Countdown" stopwatch that counts the time remaining to get to a certain date (in case 30 November). I pass this information on; days, hours, minutes and seconds. The thing is, I wanted…