因式分解-Java板块造梦空间论坛-技术交流-造梦空间论坛

因式分解

直接上源码,看不懂评论区留言~

package taolun;
import java.util.Scanner;
public class fenjie {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("输入整数");
int a = input.nextInt();
input.close();
System.out.print(a+"=");
for (int i = 2; i <= a; i++) {
while (a%i==0) {
System.out.print(i);
a/=i;
if (a!=1) {
System.out.print("*");
}
}
}
}
}
package taolun;

import java.util.Scanner;

public class fenjie {

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner input = new Scanner(System.in);
    System.out.println("输入整数");
    int a = input.nextInt();
    input.close();
    System.out.print(a+"=");
    for (int i = 2; i <= a; i++) {
      while (a%i==0) {
        System.out.print(i);
        a/=i;
        if (a!=1) {
          System.out.print("*");
        }
      }
    }
  }

}
package taolun; import java.util.Scanner; public class fenjie { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.println("输入整数"); int a = input.nextInt(); input.close(); System.out.print(a+"="); for (int i = 2; i <= a; i++) { while (a%i==0) { System.out.print(i); a/=i; if (a!=1) { System.out.print("*"); } } } } }

 

请登录后发表评论

    没有回复内容

© 造梦空间论坛
❤富强❤