This file contains hidden or 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 Prime { | |
| public boolean isPrime (int input1) { | |
| if (1 == input1) return false; | |
| for (int i = 2; i <= Math.sqrt(input1); i++) { | |
| if (input1 % i == 0) { | |
| //System.out.println("1"); | |
| return false; | |
| } | |
| } |
This file contains hidden or 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
| package com.w3epic; | |
| import java.util.*; | |
| public class Combination<T> { | |
| // combinations = blank i.e. {} initially, currentLevel = 0 initially | |
| /* getCombinations(String symbols, int parent, List<Integer> combinations, int currentLevel, int targetLevel) | |
| * List<String> symbols: contains symbols like 1234 or abcd | |
| * List<String> parent: parent node which will be combined with the symbols, initially 0 | |
| * List<List<String>> combinations: its the data to be passed while calling, it'll carry the result, initially blank ArrayList(Integer) | |
| * int currentLevel: current level of tree i.e. current combination digit count, initially 0 |
NewerOlder