fork download
  1. class simp {
  2. public static void main(String[] args){
  3. int[] ns={4,1536,51478,46410,7673,4096};
  4. int[] ds={8,78360,5536,119340,4729,1024};
  5. int x=0,n2=0,d2=0;
  6. for(int y=0; y<ns.length; y++){
  7. if(ds[y]<ns[y])
  8. x=ds[y];
  9. else
  10. x=ns[y];
  11. for(int i=1; i<=x;i++){
  12. if(ns[y]%i==0&&ds[y]%i==0){
  13. n2=ns[y]/i;
  14. d2=ds[y]/i;
  15. }
  16. }
  17. if(n2==0)
  18. n2=ns[y];
  19. if(d2==0)
  20. d2=ds[y];
  21. System.out.println(ns[y]+"/"+ds[y]+"= "+n2+"/"+d2);
  22. }
  23. }
  24. }
Success #stdin #stdout 0.11s 320512KB
stdin
Standard input is empty
stdout
4/8= 1/2
1536/78360= 64/3265
51478/5536= 25739/2768
46410/119340= 7/18
7673/4729= 7673/4729
4096/1024= 4/1