3,375 questions
-1
votes
2
answers
68
views
Finding the 1000th prime number (python) debug
I am attempting to write a code to calculate the 1000th prime number and I'm running into an issue with my loop counter that i don't understand.
prime_test = 1
count=0
for count in range(0,1001):
...
1
vote
1
answer
142
views
there's a problem when dealing with prime factorization
I've done this exercise, it was about finding if a number is "ugly" or not. A number is ugly if it has only 2, 3, or 5 as factors. otherwise, it's not ugly.
this is my solution:
include <...
1
vote
1
answer
68
views
Prime k tuples with Sage
As an example, suppose I search for prime numbers in the arithmetic progression $30n+11$ ( with $$ simulated LaTeX math mode), To print these prime numbers in Sage, I use the following
sage : [30*n+11 ...
1
vote
1
answer
171
views
Program keeps saying "Not a prime number" for any number I enter
So this is my first time writing a post here. I'm very new to the assembly language and started the learning journey with emu8086.
Recently I wrote a program that detects if the number entered is ...
-1
votes
1
answer
56
views
what is wrong with the code as i am unable to print 3 and 2
I am unable to get all the prime numbers printed .can someone help me with this .I get all the values except 2 and 3 . It starts with 5 .
public static void primesinRange(int n) {
int flag=1;
int ...
0
votes
2
answers
111
views
Numbers which only have non-gaussian primes as prime factors
I am a mathematician who is interested in the product of non-gaussian primes. A prime p is called non-gaussian, if p mod 4 = 1.
It is easy to generate an ongoing list of natural numbers in Python:
...
-6
votes
1
answer
76
views
issue in loop of finding prime number in java [closed]
I know the mistake here is in the for loop as it should be i=2 but if i put it as i=1 then why is it not entering in the loop .could someone dry run this code and tell me how exactly is this an issue
...
0
votes
2
answers
9k
views
Python program to find all prime numbers in the range 1 - n
Hi I know there are lots of solutions to this problem but I wanted some help finding out why my answer is wrong.
Here's my answer:
number = int(input("enter a number: "))
for n in range(2, ...
0
votes
2
answers
76
views
Find an element in a matrix M*M of numbers which have exactly 3 divisors in given time?
This was a task given on a coding competition a few months ago, and its still bugging me now. I did solve it, but my code did not give the result in required time for 3 test samples, likely due to the ...
1
vote
1
answer
120
views
How can check if the digits of a number are prime and if so multiply them in C
The problem says that the user will input numbers till he inserts 0 (exit) then if there are any prime digits in that given number, the program shall multiply them.
For example:
input : 4657
output : ...
2
votes
2
answers
186
views
Haskell list recursion - why does one work and not the other?
Anyone familiar with Haskell will have likely seen this implementation of the Fibonacci sequence.
fibs = 0:1:zipWith (+) fibs (tail fibs)
The way I understand this is as follows:
Haskell's lazy ...
1
vote
1
answer
309
views
How can i multiply the prime numbers of a number from user input and display it in C language
So I started learning C language for Uni and got stuck with this exercise, I found a way to ge the prime numbers of a number but I don't know how to multiply the prime numbers and display them.
int ...
1
vote
1
answer
135
views
how to check among big prime numbers for condition
Out of prime numbers less than 201920190 how to find those that dont have digit '7' in their str representation? I need to count the number(count) of such prime numbers that have no '7' in them.
Std ...
0
votes
1
answer
146
views
Sieve of Eratosthenes with nested for loops
This is a very simple question about python. I was trying to get a list of prime numbers so I tried
primes = [2]
for i in primes:
for j in range(50):
if j%i != 0:
primes.append(j)
...
0
votes
1
answer
57
views
I'm getting a weird error for printing n prime numbers
def prime(n):
if n==2 or n==3:
return True
if n==1:
return False
f=True
for i in range(2,int(n**0.5)+1):
if n%i==0:
f=False
break
...
1
vote
0
answers
209
views
How to make an efficient prime generator in python using wheel factorisation
I've been trying to make an efficient prime generator that successfully utilises wheel factorisation to be faster than a basic sieve of Eratosthenes implementation but my code ends up being a lot ...
0
votes
1
answer
104
views
Prolog - Display prime numbers
I am new to Prolog programming so still learning. I'm tryingto create a program that accepts a value X and returns a list of all prime numbers between 6 and X. I'll also be later adding an error ...
1
vote
1
answer
287
views
Prime Factorization in Haskell to return a list of tuples giving the number and the power
I have been trying to learn haskell by trying to do some simple problems.
The Problem
Currently, I am trying to implement a function primeFactorization :: Integer -> [(Integer, Integer)] such that ...
0
votes
0
answers
125
views
Double Segmented Primes Sieve
In cases of low memory available I thought it was possible to implement a double-segment sieve to find prime numbers in a neighborhood of n. In practice, a segmented sieve has dimension dim_seg_1 for ...
-1
votes
1
answer
199
views
How can I fix "SyntaxError: invalid error" for function is_prime? [closed]
There is a syntax error in line 3. I'm unsure of how to correct the error.
Write a python function is_prime() which takes one integer as an argument and returns True or False (boolean values). If the ...
1
vote
2
answers
100
views
Prime number check doesn't work as it should
I'll try to keep this short. So my task is to find the last prime number in an array, if there's any. But right now my program assigns any number it wants from the array to the lastPrimeNumber ...
-4
votes
2
answers
1k
views
check if number is prime using recursion with only one parameter in c language [closed]
I've got a task in my lesson to write a function that will check if a number is prime, it will return 1 if it is and 0 if it is not and all of that to do recursively. the function will look like that :...
2
votes
1
answer
115
views
Algorithm for calculating primes in an interval not working
I am trying to come up with an algorithm that can find all primes from a starting to an ending number, without starting at 2 and using the Sieve of Eratosthenes to calculate all primes to the ending ...
0
votes
1
answer
543
views
Does the size of the prime number in Shamir's Secret Sharing affect the security of the sharding?
I've been working on an implementation of Shamir's Secret Sharing, and was wondering if the prime number selected will impact on the security. This is mainly because I've seen some implementations on ...
0
votes
3
answers
740
views
Storing numbers larger than Big integer C#
I am having a really hard time finding a way to store massive prime numbers in c#. I tried everything but nothing worked out for me. For example. How can I store this number.
...