Created
October 8, 2016 14:06
-
-
Save ptahchiev/2c52182feb7db9a63d882b12659afba5 to your computer and use it in GitHub Desktop.
sample2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sample2 { | |
public static void main(String[] args) { | |
int number = 17; | |
System.out.println(imperative(number)); | |
System.out.println(declarative(number)); | |
} | |
public static boolean imperative(int number) { | |
for (int i = 2; i < number / 2; i++) { | |
if (number % i == 0) { | |
return true; | |
} | |
} | |
return false; | |
} | |
public static boolean declarative(int number) { | |
return IntStream.range(2, number / 2).filter(e -> number % 2 == 0).findFirst().orElse(-1) != -1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment