All Questions
41 questions
3
votes
2
answers
158
views
Factor 999999 numbers as fast as possible
My code finds the prime factorization of numbers, ordering the prime numbers from least to greatest.
It prints a list of 999999 prime factorizations (which can be changed if you edit the function call ...
1
vote
2
answers
155
views
Improving Project Euler code problem #10
So, I just finished Problem 10 on Project Euler, but it took about 3 to 4 minutes for my output to come out, due to bad coding, I guess, any suggestions on how could I optimize my code?
Question
The ...
7
votes
2
answers
2k
views
Arranging numbers in a circle such that the sums of neighbors and sums of diametric opposites are prime
I need to create a circle with numbers from 1 to n , however it is necessary to respect some rules:
All numbers from 1 to n are used in the circle only once.
The sum of two consecutive numbers ...
6
votes
2
answers
260
views
Goldbach conjecture solution finder
The Goldbach conjecture says: any even number greater than two can be represented by the sum of two prime numbers.
G(n) = { (p1, p2) | p1 + p2 = n, p1 and p2 are prime numbers with p1 < p2 }
For ...
2
votes
1
answer
1k
views
Finding the first 10 million primes
I'm trying to find the first 100 million primes and am trying to find the most efficient way to do it. Can I get some advice on how I could improve this?
...
0
votes
1
answer
361
views
Finding prime numbers performance
I am writing an app that finds prime numbers within a specified range. Currently i am updating almost every part of the app and i have also changed the way i find prime numbers. The problem is that ...
97
votes
5
answers
19k
views
Load fifty million integers as quickly as possible in Java
I am working my way through Project Euler. Many of the problems deal with prime number calculations: this is the type of code that can be extracted into a separate class and reused.
While calculating ...
3
votes
3
answers
609
views
First n primes optimization
Pretty standard. Generates the first n primes, input via a scanner.
...
6
votes
2
answers
2k
views
Find prime positioned prime number
This is a question from programming contest. This contest is already over.
Now, all the prime numbers are arranged sequentially in ascending order. i.e:- 2, 3, 5,7...and so on. Now, your task is to ...
2
votes
1
answer
157
views
Yet another Sieve of Eratosthenes in Java
I wanted a reusable class for generating a list of primes till some arbitrary (but reasonable) limit. So, I wrote a class Primes that implements the Sieve of ...
2
votes
2
answers
339
views
Finding all the prime factors of a number
I want to calculate all the prime factors of a number in the range 2 ≤ N ≤ 107. Here is my function:
...
4
votes
1
answer
398
views
Sieve of Eratosthenes Primes Efficiency
I'm fairly new to Java and was trying to make a program that's generates the primes from 2 - 100. I originally had a design of my own making but it was fairly inefficient so I did some research and ...
5
votes
2
answers
944
views
Find the next prime number — flow control of nested `for` loops
This code works perfectly, but it bothers me. Having a labeled, nested for loop, with a true condition, a ...
4
votes
1
answer
695
views
Calculating the nth prime number for huge BigIntegers
I wrote this simple class for calculating the nth prime:
...
4
votes
2
answers
2k
views
Find the highest occurring digit in the prime numbers present between L and R (both inclusive)
Given two numbers L and R, find the highest occurring digit in the
prime numbers present between L and R (both inclusive). If multiple
digits have the same highest frequency print the largest of ...