/* (Start of program header comment)
* Copyright and version Declaration section of the program
* Copyright (c) 2016, Guangzhou Science and Technology Trade Vocational College, Department of Information Engineering students
* All rights reserved.
* File name: Blue Bridge Cup title
* Author: Pengjunhau
* Completion Date: April 01, 2016
* Version number: 001
* Description part of task and solution method
* Description of the problem:
A prime number is one that cannot be divided equally. For example: 2 3 5 7 11 etc.
9 = 3 * 3 indicates that it can be 3 equal and therefore not a prime number.
Our country was founded in 1949. If you only give 1 9 4 9 of these 4 digital cards,
They can be placed in order (but the cards can not be placed upside down, we are not in the brain teasers!). ),
So, how many 4-bit primes can you make?
* Input Description:
* Program output: For example: 1949,4919 all meet the requirements.
* End of comment on the program head
*/
On the code:
public class Main {
public static void Main (string[] args) {
for (int i = 1499; i < 9941; i++) {
if (f (i) ==1) {
int a = I%10;
int b = i/10%10;
int c = i/100%10;
int d = i/1000;
if (a==1 | | a==4 | | a==9) && (b==1 | | b==4 | | b==9) && (c==1 | | c==4 | | c==9) && (d==1 | | d==4 | | d==9)) {
System.out.println (i);
}
}
}
}
public static int F (int n) {
if (n==0| | N==1) {
return 0;
}
for (int i = 2; i < n; i++) {
if (n%i==0) {
return 0;
}
}
return 1;
}
}
Fourth session Blue Bridge Cup Javac Group-prime number