#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
On this page of the site you can watch the video online Java Program To Check Prime Numbers | Print Prime Numbers | Java Practice Problems | Code Bode with a duration of hours minute second in good quality, which was uploaded by the user CodeBode 19 May 2020, share the link with friends and acquaintances, this video has already been watched 2,317 times on youtube and it was liked by 24 viewers. Enjoy your viewing!