Skip to main content

All Questions

6 votes
4 answers
436 views

Optimal Solution for the Four Divisors Problem on LeetCode

I recently encountered the Four Divisors problem on LeetCode and managed to achieve a 100% beat rate with my solution. I'd like to share it with you all and gather feedback on its effectiveness and ...
BrunoBarreto's user avatar
8 votes
1 answer
330 views

Find "prime polynomials" for a user's given prime, bounds, and degree

Very amateur programmer and first-time poster here. The program I wrote asks the user for a prime number, a lower and upper bound, and a degree (all of these are integers). I want to generate a list ...
Gizmo's user avatar
  • 183
3 votes
2 answers
89 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 ...
Linus Rastegar's user avatar
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 ...
Linus Rastegar's user avatar
4 votes
3 answers
2k views

Lucas sequence implementation

Could you suggest any improvements in this Lucas sequence's implementation: ...
Mike's user avatar
  • 113
2 votes
1 answer
577 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 ...
Jacob's user avatar
  • 31
3 votes
2 answers
204 views

Evaluating f(N,R) mod(m)

The goal is to find \$f(n,r)\mod(m)\$ for the given values of \$n\$, \$r\$, \$m\$, where \$m\$ is a prime number. $$f(n,r) = \dfrac{F(n)}{F(n-r) \cdot F(r)}$$ where $$F(n) = 1^1 \cdot 2^2 \cdot 3^...
Manu's user avatar
  • 33
14 votes
3 answers
8k views

Tonelli-Shanks algorithm implementation of prime modular square root

I did an implementation of the Tonelli-Shanks algorithm as defined on Wikipedia. I put it here for review and sharing purpose. Legendre Symbol implementation: ...
Phong's user avatar
  • 263