Skip to main content

All Questions

Tagged with
4 votes
1 answer
564 views

Prime factorization algorithm by using the multiprocessing module of Python

I may introduce a Python code of prime factorization which is from my personal project that I'm working on. ...
MYUN's user avatar
  • 59
4 votes
4 answers
221 views

My prime number generation program in Python

So I did my own take (I wrote my own algorithm) for generating prime numbers from 1 to 1000. ...
Aryan's user avatar
  • 61
1 vote
1 answer
54 views

Python Prime Search Slower Optimization

I have these 2 version of code. Both are looking for all primes under a certain ceiling value. The first is testing against the set of all odd numbers. The second in testing against the set of all 6k-...
Desmond Rhodes's user avatar
6 votes
2 answers
104 views

Finding consecutive primes matching p, p + 4, p + 6, p + 10, p + 12, p + 16

Someone asked about this question on the main StackOverflow. The full question is: Given a value N, find p such that all of ...
blueteeth's user avatar
  • 161
2 votes
2 answers
348 views

Finding the nth ugly number

I'm trying to optimize my solution to this LeetCode problem: Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the ...
nz_21's user avatar
  • 1,051
12 votes
3 answers
5k views

Python π = 1 + (1/2) + (1/3) + (1/4) - (1/5) + (1/6) + (1/7) + (1/8) + (1/9) - (1/10) ...1748 Euler

I wrote this code to show that my reddit post is correct. After the first two terms, the signs are determined as follows: If the denominator is a prime of the form 4m − 1, the sign is positive; if ...
FodderOverflow's user avatar
6 votes
1 answer
921 views

Decompose any number to its prime factors raised to their respective powers

A simple code which takes the given number as input and gives all of its prime factors raised to their respective powers. It works well up to 10⁶; after that it slows down greatly for some numbers. ...
random_npc's user avatar
5 votes
2 answers
1k views

Prime Number Generator (6n + 1 or 6n - 1)

This generator is like most where it brute forces an integer: it see whether the integer is divisible by any of the primes; if so, then it's not a prime and vice versa. This though only compares ...
Anthony Pham's user avatar
14 votes
4 answers
2k views

Codechef: Prime Number Generator

Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers! Input The input begins with the number t of test cases ...
Subham Goyal's user avatar
5 votes
1 answer
1k views

Sieve of Atkin in Python

I recently implemented the Sieve of Atkin prime generating algorithm in Python. Though I know the term "pythonic" isn't exactly set in stone, I can tell that my program doesn't quite take advantage of ...
daOnlyBG's user avatar
  • 171
7 votes
4 answers
1k views

Python Prime Testing

This code seems surprisingly fast at checking if a number is prime. ...
Neil A.'s user avatar
  • 263
5 votes
1 answer
911 views

Number of divisors of a factorial

I was solving the DIVFACT problem from Sphere Online Judge: Given a number, find the total number of divisors of the factorial of the number. Since the answer can be very large, print the answer ...
sid597's user avatar
  • 153
9 votes
6 answers
4k views

Goldbach’s Conjecture in Python

Input Format Input starts with an integer n (1 ≤ n ≤ 100) indicating the number of cases. The following n lines each contain a test case of a single even number x (4 ≤ x ≤ 32000). Output Format For ...
Gurupad Mamadapur's user avatar
7 votes
2 answers
913 views

Counting Fermat witnesses and liars

We were asked to implement a program that calculates the number of Fermat witnesses and liars for odd numbers greater 1. This involves Fermat’s little theorem. Fermat’s little is used to identify ...
kleinfreund's user avatar
  • 3,701
3 votes
2 answers
216 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

15 30 50 per page