You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we look at the python implementation, we define a function and give it and attribute `(num)`. We introduce the `if` statement and `for` loop to iterate over the funtion and check if it matches the requirements. We later propmt user to input a number and the code will verify if all the requirements are met to qualify it as a prime number.
34
+
35
+
36
+
37
+
### Java Explanation
38
+
39
+
In java we have a different approach. Unlike python we define our class using `(public class)` named `PrimeNumber`.Both Python and java use conditional statement loops to iterate over the functions. The function is later iterated on the main class
40
+
41
+
42
+
43
+
### Difference
44
+
45
+
1. Python uses `def` keyword to define a funtion while Java uses, `public static boolean` to define a function.
46
+
47
+
2. Java uses `System.out.print()` to print out the statement and python uses `print()` to print statement.
48
+
49
+
50
+
3. I notice i have to import `java.util.Scanner` to prompt user to input a number while python you only need to use, `input()`
0 commit comments