All Questions
Tagged with time-limit-exceeded primes
66
questions
2
votes
1
answer
134
views
Count how many numbers in a range have exactly three divisors
The challenge
Given array a of n numbers, I need to count how many positive numbers less than each aᵢ have exactly 3 divisors.
Constraints
1 <= aᵢ <= 2.5 * 10¹³
In other words,
the minimum ...
0
votes
2
answers
206
views
A function to find all the primes between two numbers whose reverse is also a prime and doesn't include palindrome, in JS
I am trying to solve a challenge in which I have to write a function that takes in two numbers as arguments and returns an array containing numbers between them which are prime and their reverse is ...
7
votes
4
answers
503
views
Finding the first pair of prime numbers that have some specified difference
I tried printing the first pair of prime number in between a list of numbers with a particular difference. But my run time is still too high (for large range of numbers). I want to reduce the run time ...
2
votes
1
answer
254
views
Hackerrank problem -"Another Prime Problem"
I came across this issue in the problem titled: Another Prime Problem. Here's my solution with JavaScript which passed test case-1, but for other test cases it led to timeout.
...
2
votes
1
answer
919
views
Codewars: Prime Streaming (PG-13)
I'm timing out on Codewars' Prime Streaming kata. Below is my code:
...
3
votes
1
answer
702
views
Project Euler #357: Prime generating integers
Project Euler Problem 357 asks:
Consider the divisors of 30: 1,2,3,5,6,10,15,30.
It can be seen that for every divisor d of 30, $$d+30/d$$ is prime.
Find the sum of all positive integers n ...
7
votes
1
answer
928
views
Hackerrank: Computer Game (max-flow problem with integer factorization)
I am working on a coding challenge from the Hackerrank site. Given two equal-length arrays of integers, with values from 2 to 109, find the maximum number of times we can remove a pair (Ai, Bj) where ...
11
votes
5
answers
3k
views
A faster way to compute the largest prime factor
I am self-learning js and came across this problem(#3) from the Euler Project
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
...
6
votes
1
answer
252
views
Counting primes in a range whose digits are all prime
Codewars Kata: Given integers a and b, count all primes p where a ≤ p < b and the digits of p are all prime. b may be as large as 107.
To start with, I hardcoded all valid 1903 primes in \$[1, 10^...
1
vote
2
answers
322
views
Work out largest prime factor of a number
I am trying to get better at problem solving, so I am going through challenges on Project Euler.
Problem:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the ...
2
votes
2
answers
6k
views
The next prime number in Python
I have written a solution to a DM::OJ exercise to find the next Prime Number after a given number (input). I'm seeking to optimize it so that it will run for any number up to ...
1
vote
3
answers
880
views
Kattis prime reduction challenge
I am solving the Prime Reduction challenge on Kattis.
Consider the following process, which we’ll call prime reduction. Given an input x:
if x is prime, print x and stop
factor x into its ...
0
votes
2
answers
167
views
Euler Project #3 Largest prime factor timeout
I have been recently trying my hands on Euler's Project through HackerRank and got stuck with project #3 where you have to find the Largest Prime Factor.
Question: The prime factors of 13195 are 5, 7,...
5
votes
1
answer
324
views
Find primes that are also primes when its digits are rotated
The program below is meant to find all of the fare prime numbers under a user specified value. A fare prime being a number that when its digits are rotated, each combination makes a prime number. An ...
3
votes
2
answers
235
views
Project Euler #7: Nth prime number
I was solving Project Euler #7 on Hackerrank
but for two cases, execution time is more than 2 sec.
Can you help with optimizing? I'm new to programming.
...