All Questions
Tagged with mathematics python
19
questions
16
votes
1
answer
782
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 ...
10
votes
2
answers
21k
views
26
votes
4
answers
1k
views
Generalized Project Euler 1: A sledgehammer to crack a nut
The problem
Project Euler 1 is one of the most asked questions on site. However I wanted to solve the more general problem of division.
Multiples of a list
If we list all the natural numbers ...
9
votes
6
answers
3k
views
Decide whether a triangle is isosceles or not
I think I have pretty much the best code you can get when it comes to this particular task, but I'm always open to improvement. This code will check everything I can think of to make sure that it will ...
8
votes
4
answers
8k
views
Pi-calculating program
I saw this question and answer about calculating pi on Stack Overflow, and I decided to write my own program for calculating pi. I used Python and only integers (I didn't want to use floating point ...
7
votes
2
answers
3k
views
Magic Square (Python)
Problem
Write a method to return a boolean if an input grid is magic square.
A magic square is a \$NxN\$ square grid (where N is the number of cells on each side) filled with distinct positive ...
7
votes
2
answers
2k
views
Helper function to solve Project Euler question 26
Project Euler problem 26 asks us to:
Find the value of d < 1000 for which 1/d contains the longest recurring cycle in its decimal fraction part.
I wrote this function in Python to find the ...
7
votes
1
answer
125
views
Weighted phase Laplacian formula
We have the following equation (weighted phase Laplacian):
\$c_{i,j} = U(i,j)\Delta^{^x}_{i,j} - U(i-l, j)\Delta^{x}_{i-1,j} + V(i,j)\Delta^{y}_{i,j} - V(i,j-1)\Delta^{y}_{i,j-1}\$
Where
\$U(i,j) = ...
7
votes
4
answers
822
views
Are there any bugs or ways to make my divisor code better?
After coding my divisor code which I did as a practice for my GCSE stuff which I have to take soon, I have decided to ask the community if there are any bugs or ways I can improve my code.
...
6
votes
2
answers
112
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 ...
5
votes
3
answers
2k
views
Find smallest number of squares that sum to a number
Leetcode problem 279 “Perfect Squares” is:
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...)
I wrote the following solution:
...
5
votes
1
answer
5k
views
Project Euler Problem 12 - Highly Divisible Triangular Number - Python Solution Optimization
Project Euler Problem 12 asks (paraphrased):
Considering triangular numbers Tn = 1 + 2 + 3 + … + n, what is the first Tn with over 500 divisors? (For example, T7 = 28 has six divisors: 1, 2, 4, 7, ...
5
votes
1
answer
67
views
Exploring the space of 8 parameters of a physics problem to then be evaluated in ODE integrator as LSODA millions of times, efficently
there's a function in one of the scripts I've been working on that I really want to improve.
Disclaimer: Being honest, I'm not really very good at programming but I've been learning day to day and it'...
4
votes
1
answer
667
views
Calculate the Euler-Mascheroni constant without the math module
The below code was written to generate γ, for educational purposes.
Single threaded, no functional zeroes required, no binary splitting(which can all be used to compute competitively like y-cruncher, ...
3
votes
2
answers
979
views
Extended Euclidean algorithm
I have programmed the extended euclidean algorithm. Is this a good approach?
...