题解 | #牛牛的素数和#
牛牛的素数和
http://www.nowcoder.com/practice/d748d79f68ab443482c5547d93824f50
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int first = scanner.nextInt(); int second = scanner.nextInt(); int sum = 0; for(int index = first; index <= second; index++){ if(check(index)){ sum += index; } } System.out.print(sum); } private static boolean check(int num){ if (num < 2) return false; for (int index = 2; index <= num / index; index++ ) { if (num % index == 0) { return false; } } return true; } }