00:01
This promor asked to write a program that allows the user to enter number and then we return whether that number is prime or not.
00:08
So the first thing you're going to want to do is create a boolean variable.
00:13
I just called it prime and set that equal to true.
00:16
This variable will basically manipulate and it'll help us print out at the end whether the number is prime or not.
00:26
So then you're going to create a scanner variable, right? i just called it in because we're collecting user input, so we need a scanner variable.
00:34
We asked the user to enter a number, and then we collect that number by doing in.
00:42
Nextint, and we set that equal to a new variable.
00:46
You can initialize, and i just called it numb.
00:50
All right, and then how do we determine whether numb this user -inputed integer is prime or not? well, in order to do that, i've created this four loop here.
01:01
And if you look at the problem, again, it states a number is prime.
01:06
If it only has two factors, right, one in itself.
01:10
If it has other factors, you know, between one in itself, for example, four is divisible by two, right? that is a number between one and four there.
01:22
Then it's not prime, right? four is not prime since it's divisible by two.
01:27
Whereas a number like five is prime, right, because two, three, four, right, don't divide five...