[Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解
2016-02-19 22:36
513 查看
素数 A prime is an integer greater than one whose only positive divisors are one and itself.
整数的素因子分解是乘积等于此素数的集合。
例如:3757208 = 2*2*2*7*13*13*397
没看懂...
整数的素因子分解是乘积等于此素数的集合。
例如:3757208 = 2*2*2*7*13*13*397
public class Factors { public static void main(String[] args) { // Print the prime factors of N. long N = Long.parseLong(args[0]); long n = N; for (long i = 2; i <= n/i; i++) { // Cast out and print i factors while(n % i == 0) { n /= i; System.out.print(i + " "); // Any factors of n are greater than i. } } if (n > 1) System.out.print(n); System.out.println(); } }
没看懂...
相关文章推荐
- 从头认识Spring-2.8 基于java注解的配置(基本没有xml)
- Java [Leetcode 228]Summary Ranges
- 关于 Eclipse
- 深入理解Spring IOC
- 定制化Azure站点Java运行环境(3)
- 定制化Azure站点Java运行环境(2)
- SQL Developer报错:Unable to find a Java Virtual Machine解决办法
- LEEDCODE 12 Integer to Roman (JAVA题解)
- Java反射机制
- spring mvc中的@PathVariable[动态参数类似于spring中的通配符功能]
- Java [Leetcode 204]Count Primes
- java基础—java的Io操作学习(3)
- java多线程设计模
- andriod Java中度转度分秒
- CS 106A JAVA学习
- Eclipse简介、下载安装与插件
- jdk自带多线程处理神器Executor
- [Introduction to programming in Java 笔记] 1.3.7 Converting to binary 十进制到二进制的转换
- Spring Cache
- Eclipse 中建立 Maven Web项目