# Questions tagged [mathematics]

For code that aims to solve problems in all branches of mathematics. (Please do NOT use this tag for incidental trivial use of arithmetic. A simple test to apply is: would an amateur or professional mathematician take an interest in the question?)

450 questions
Filter by
Sorted by
Tagged with
109 views

### Counting Hamiltonian triangulations (OEIS 3122)

I'm trying to translate formulas from the 3122th sequence in OEIS database, in particular this one: ...
1k views

### Arithmetic Progression

I had to write a program that would complete an arithmetic progression based on the users input. The user would provide the third term in the series, the third from the last term, and the sum of all ...
540 views

Still pretty new to coding. I posted that Twin Primes Finder the other day and you guys were a great help so thanks. Here's my quadratic equation solver: ...
2k views

### Calculating distance and angle between two points, C# program

I like to think I'm an intermediate programmer, but I learned to code with the Unity engine so I'm still getting used to not using it, and I've never had someone review my code before. I don't know ...
104 views

I'm working with some math-heavy code in JavaScript. I just realized that there's a render that currently takes about 30 minutes. 95% of that time is spent in a single ~40 line function that I've ...
77 views

### Number Theory Inhibitor Calculator

I've been working on generating primes and prime products quickly to aid me in my research on prime numbers, their density, etc. The answer to my Large Number Limit Extravaganza question proved to be ...
580 views

### Large Number Limit Extravaganza

I am writing a program that computes $$n-n \cdot \left(\prod_{i=1}^n (1-\frac{1}{p_i})\right)$$ which is rewritten in my code as: \left(1-\left(\prod_{i=1}^n(1-\frac{1}{p_i})\right)\right) \cdot ...
129 views

### Logarithmic growth counter

I'm looking for a way to have an logarithmic incremental counter. The counter goal is related to a numeric value than goes from 1 to Infinity. The counter maximum value should be 1000. The sequence ...
3k views

### Compute Gini Coefficient

Recently, I was given a math assignment to calculate Gini Indexes for a table of percent distributions of aggregate income. The table takes the form of: ...
241 views

### Time limit exceeded on finding out the GCD and LCM of a Python list

I'm doing this HackerRank problem: Consider two sets of positive integers, $A=\{a_0, a_1, \ldots, a_{n-1}\}$ and $B=\{b_0, b_1, \ldots, b_{m-1}\}$. We say that a positive integer, $x$, is ...
102 views

285 views

### Zeckendorf Representation of positive integer

Zeckendorf's theorem states that all positive integers crepresented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive ...
5k views

### C++ code to find distance between line and point

So I made this simple program that allows users to construct points and lines and then return the smallest distance between a given point and a line. In doing so I have used some OOP concepts and ...
531 views

### Ruby function to find numbers whose sum of squares of divisors is a perfect square

I am doing a problem my buddy gave to me and I have my solution which works but needs to be optimised. I have tried to optimise it as much as I can with my knowledge but it seems there is still room ...
147 views

### Large Power Mod - Extreme Efficiency

I've implemented my own 'power-mod' procedure which will compute a^b 'mod' n for some large b and even larger ...
238 views

### Z^m number system in Rust version 2

A $Z^m$ number system includes integers in the interval $[0, m)$ when $m > 0$ or $(m, 0]$ when $m < 0$. The code defines a trait Mod to represent ...
688 views

### Z^m number system in Rust

A $Z^m$ number system includes integers in the interval $[0, m)$ when $m > 0$ or $(m, 0]$ when $m < 0$. The code defines a trait Mod to represent ...
91 views

### Code to measure the length of binary numbers in terms of English nomenclature

"ONE" and "ZERO". The basis of this project is in this video -> links to his code can be found in description In it the speaker asks you to check his math; I wrote my own code and then compared it ...
1k views

### Lucas sequence implementation

Could you suggest any improvements in this Lucas sequence's implementation: ...
203 views

### Estimating the total production count from a few random serial numbers

This is basically my attempt to the German Tank Problem in which we are given a few serial numbers and expected to return an estimation of the total production count. Such as, if 4 tanks are captured ...
1k views

### Calculating exponential moving averages with multiples threads

I calculate the moving averages of a specific measure. However, multiples threads can access this class in order to compute the average. ...
468 views

### Calculating the statistical Mode(s) of a (possibly multi-modal) set of elements

I am trying to come up with the most performant way of calculating the statistical Modes of a std::vector, obeying two conditions: 1) my function should not ...
347 views

### Generating numbers that are a product of consecutive primes

I have implemented a correct but horribly coded solution to Project Euler Problem 293. An even positive integer N will be called admissible, if it is a power of 2 or its distinct prime factors ...
300 views

### Finding b and e such that b to the power of e is closest to a given number

The question is to find a number with absolute minimum difference from a number of the form be. I came up with the below code which takes 4 seconds to solve each test case on an average however it has ...
1k views

### Squaring the two digits in the middle of a four-digit number

I got a four-digit positive number. I need to square the two digits in middle to generate a new number on which the same procedure is applied. The numbers get saved in a list. This loops as long as ...
203 views

76 views

### Text font size adapting to space

In order to practice my programming skills, I am trying to implement a Button class, to use in pygame. I know there are libraries like PGU, I do this to improve in programming. I spent a bit of time ...
127 views

### Roots of Unity in R

I have a paper on the definition of (i) available here. I was curious about the simultaneous real numbers associated with the roots of unity, and noticed there was not a routine in R. I have this ...
223 views

### Function to check truth value of a specific statement

I want to check the truth of A + B - (A & B) == A | B for N-bit numbers. For example, here's a "truth" table for 2-bit numbers. (I know I'm taking liberty with ...
13k views

### Different neural network activation functions and gradient descent

I've implemented a bunch of activation functions for neural networks, and I just want have validation that they work correctly mathematically. I implemented sigmoid, tanh, relu, arctan, step function, ...
The reliability polynomial (specifically, the all-terminal reliability polynomial) is, given a value $0 \le p \le 1$, outputs the probability that a given graph $G$ is connected. Note: at the ...