0

Let array =[1, 2,3,4,5,6,7,8,9,10] how get prime numbers from this array

I want only prime numbers using for loop

7th Jul 2022, 6:13 AM
Padala Bala Sirisha
Padala Bala Sirisha - avatar
5 odpowiedzi
+ 2
Padala Bala Sirisha You have to check array value but you are checking iteration value 'i' if (array[i] % 3 == 0)
7th Jul 2022, 6:21 AM
A͢J
A͢J - avatar
+ 2
Drop 1 Now As long as array is not empty First value of array f is a prime Drop all elements that a devisible by f, also f
7th Jul 2022, 7:20 AM
Oma Falk
Oma Falk - avatar
+ 1
Padala Bala Sirisha Iterate array using for loop and get reminder of each element. If reminder is 0 then print that element
7th Jul 2022, 6:20 AM
A͢J
A͢J - avatar
0
I don't get it
7th Jul 2022, 3:14 PM
Padala Bala Sirisha
Padala Bala Sirisha - avatar
0
Padala Bala Sirisha Checking if a number is prime is a very frequently answered question, here, there, and everywhere. Just search for codes and other questions to see how it can be done. Just make sure you understand how to get the remainder of an integer division. It's way too easy, but mandatory. Then, loop thru array items and test each one. Or use filter functions. Or whatever suits best. But don't wait. Start in Code Playground, link the code in the question description, and bring your difficulties here.
7th Jul 2022, 5:54 PM
Emerson Prado
Emerson Prado - avatar