import java.util.Arrays; import java.util.Iterator; import java.util.TreeSet; public class problem23 { static TreeSeta ; public static void main(String[] args) { int c=0; int v[]=new int [6965]; boolean v1[]= new boolean [28124]; Arrays.fill(v1, false); for (int i = 1; i <=28123 ; i++) { if(nro(i)>i) { v[c]=i; System.out.println(v[c]+" "+ c); c++; } } System.out.println("paso1"); long co=0; TreeSet a= new TreeSet (); for (int i = 0; i < v.length; i++) { for (int j = 0; j < v.length; j++) { if((v[i]+v[j])<=28123) v1[v[i]+v[j]]=true; } } for (int i = 1; i <=28123; i++) { if(!v1[i]) co=co+i; } System.out.println(co); } public static int nro(int n ) { int c =0; for (int i = 1; i <= n/2; i++) { if(n%i==0) c=c+i; } return c; } }
martes, 14 de febrero de 2012
problem euler 23
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario