+1
-1
2'den 1000'e kadar olan sayılar. simdi yazıyım dedim amk.
public class NewMain {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
}
public void init(){
String outputString = "";
for ( int number = 2; number <= 1000; number++ ) {
String result = perfect( number );
if ( result != "0" ){
outputString += "n" + number + " is perfect."+ "ntFactors: " + result;
}
}
}
public String perfect( int value ){
int factorSum = 1;
String factors = "1 ";
for ( int test = 2; test <= value / 2; test++ ) {
if ( value % test == 0 ) {
factors += test + " ";
}
}
if ( factorSum == value )
return factors;
return "0";
}
}