Producing 100 prime number in a vector
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Abhishek
el 27 de Oct. de 2022
Respondida: David Hill
el 27 de Oct. de 2022
Hi,
I want to generate a vector in which I could check that vector for prime numbers using isprime(vector). So far I have been able to get the get a vector, but it does not give the number which are prime. Instead it gives out a vector where all the prime numbers are replaced by one and non prime with zero.
p=(2:1:600)
y=isprime(p)
I used the following code.
Thanks in advance
0 comentarios
Respuesta aceptada
David Hill
el 27 de Oct. de 2022
p=(2:1:600);
p(isprime(p))
primes(600)%better and faster
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Discrete Math en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!