primes Questions
13
Can someone please give me guidance on getting the primenumbers here? This is homework so I don't want the answer but some pointers would be greatly appreciated. It's really annoying me :(
I thin...
Promising asked 30/6, 2013 at 10:20
4
I'm trying to solve problem 3 from http://projecteuler.net. However, when I run thing program nothing prints out.
What am I doing wrong?
Problem: What is the largest prime factor of the number 600...
Hackneyed asked 7/3, 2013 at 18:47
6
Solved
I need to write a program to input a number and output its factorial's prime factorization in the form:
4!=(2^3)*(3^1)
5!=(2^3)*(3^1)*(5^1)
The problem is I still can't figure out how to get th...
Valentijn asked 17/1, 2014 at 22:5
20
Solved
So I was able to solve this problem with a little bit of help from the internet and this is what I got:
def isPrime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
return False
return True
B...
9
Solved
I'm new to Haskell.
How to generate a list of lists which contains prime factors of next integers?
Currently, I only know how to generate prime numbers:
primes = map head $ iterate (\(x:xs) ->...
Hangup asked 22/1, 2014 at 7:35
3
I have been going through prime number generation in python using the sieve of Eratosthenes and the solutions which people tout as a relatively fast option such as those in a few of the answers to ...
Schwaben asked 14/4, 2013 at 21:15
32
I would just like to ask if this is a correct way of checking if number is prime or not? because I read that 0 and 1 are NOT a prime number.
int num1;
Console.WriteLine("Accept number:");
num1 =...
Guerrero asked 1/4, 2013 at 12:7
27
Solved
Just to clarify, this is not a homework problem :)
I wanted to find primes for a math application I am building & came across Sieve of Eratosthenes approach.
I have written an implementation...
Lynseylynus asked 15/10, 2010 at 5:16
41
In Javascript how would i find prime numbers between 0 - 100? i have thought about it, and i am not sure how to find them. i thought about doing x % x but i found the obvious problem with tha...
Dematerialize asked 15/8, 2012 at 8:57
41
Solved
This is the best algorithm I could come up.
def get_primes(n):
numbers = set(range(n, 1, -1))
primes = []
while numbers:
p = numbers.pop()
primes.append(p)
numbers.difference_update(set(rang...
Georgiageorgian asked 14/1, 2010 at 23:40
21
Two part question:
Trying to determine the largest prime factor of 600851475143, I found this program online that seems to work. The problem is, I'm having a hard time figuring out how it works ex...
16
Solved
I am trying to find the fastest way to check whether a given number is prime or not (in Java). Below are several primality testing methods I came up with. Is there any better way than the second im...
Club asked 5/3, 2010 at 10:12
6
Solved
Here's my code:
def factorize(n):
sieve = [True] * (n + 1)
for x in range(2, int(len(sieve) ** 0.5) + 1):
if sieve[x]:
for i in range(x + x, len(sieve), x):
sieve[i] = False
lowerPrimes = ...
Thong asked 15/4, 2013 at 3:22
7
I'm trying to print every prime number under 2**32. Right now I'm using a bool vector to build a sieve and then print out the primes after making the sieve. It takes 4 minutes just to print out the...
Gould asked 21/9, 2013 at 1:49
1
I wanted to do some comparison between Python and Raku while also learning Raku.
Originally I wanted a much bigger script, but since the difference is already huge, I'll ask for guidance now.
I tri...
Impermissible asked 19/9, 2023 at 23:18
7
I want to create a program in C# 2005 which calculates prime factors of a given input. i want to use the basic and simplest things, no need to create a method for it nor array things etc. just simp...
Wurth asked 3/5, 2011 at 16:58
28
Solved
Could someone please tell me what I'm doing wrong with this code? It is just printing 'count' anyway. I just want a very simple prime generator (nothing fancy).
import math
def main():
count = ...
7
Solved
I wrote the following program based on the logic that a prime number is only divisible by 1 and itself. So I just go through the process of dividing it to all numbers that are greater than one and ...
30
Naturally, for bool isprime(number) there would be a data structure I could query.
I define the best algorithm, to be the algorithm that produces a data structure with lowest memory consumption for...
Humor asked 26/11, 2009 at 3:30
2
Solved
The documentation for Raku's is-prime function says the following:
Returns True if this Int is known to be a prime, or is likely to be a
prime based on a probabilistic Miller-Rabin test.
Returns F...
5
Solved
How would one implement a list of prime numbers in Haskell so that they could be retrieved lazily?
I am new to Haskell, and would like to learn about practical uses of the lazy evaluation function...
Yoshida asked 29/8, 2010 at 20:40
7
I have been trying to write Sieve of Eratosthenes algorithm in JavaScript. Basically I just literally followed the steps below:
Create a list of consecutive integers from 2 to (n-1)
Let first pri...
Whorehouse asked 18/3, 2013 at 7:0
21
Solved
I was trying to find the prime factors of a number, recorded below as 'integer' using a for loop in javascript. I can't seem to get it working and I'm not sure whether it's my JavaScript or my calc...
Louls asked 6/10, 2016 at 14:45
10
Solved
I was trying to write a simple prime number program in Java 8. Below is the program. I wanted to reduce the code in isPrime() as well. Is there something that filters the elements from 2 to n/2, an...
7
Solved
Since I'm starting to get the hang of Python, I'm starting to test my newly acquired Python skills on some problems on projecteuler.net.
Anyways, at some point, I ended up making a function for ge...
Ullund asked 6/12, 2012 at 16:18
1 Next >
© 2022 - 2025 — McMap. All rights reserved.