Java Program To Check Prime Numbers | Print Prime Numbers | Java Practice Problems | Code Bode

Pubblicato il: 19 maggio 2020
sul canale di: CodeBode
2,317
24

#primenumbers | #javatutorails | #javapracticeproblems

Hi guys,
In this video, we will learn how to check if a number is prime or not.
Let's understand what is a prime number and non-prime number
prime number - a number only divisible by 1 and itself
non-prime number - if divisible by any other number apart from 1 and itself

Algorithm/Logic
// 1. input number from the user
// 2. check divisiblity by other numbers - iterate a for loop - 2 to input/2
// 3. condition to check divisiblity using %
// 4. set a flag as false
// 5. if it is divisible print not prime; break the loop; and set flag to true
// 6. after loop completes check if flag is still false. if flag is fase print prime

Stay tuned for more practice problems



Conditional Statements In Java | if else In Java| Nested if | Java Tutorials | Code Bode -    • Conditional Statements In Java | if e...  

Conditional Statements In Java| Switch In Java| Java Tutorials | Code Bode -    • Conditional Statements In Java| Switc...  

For Loop In Java | Loops In Java | Java Tutorials | Code Bode -    • For Loop In Java | Loops In Java | Ja...  

Do While Loops In Java | Difference Between While and Do While | Java Tutorials | Code Bode -    • Do While Loops In Java | Difference B...  

Break Statement In Java | Uses of Break | Java Tutorials | Code Bode -    • Break Statement In Java | Uses of Bre...  

Continue Statements In Java | Loops In Java | Java Tutorials | Code Bode -    • Continue Statements In Java | Loops I...  

Follow Us on Instagram : code.bode


In questa pagina del sito puoi guardare il video online Java Program To Check Prime Numbers | Print Prime Numbers | Java Practice Problems | Code Bode della durata di ore minuti seconda in buona qualità , che l'utente ha caricato CodeBode 19 maggio 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,317 volte e gli è piaciuto 24 spettatori. Buona visione!