素数 A prime is an integer greater than one whose only positive divisors are one and itself.
整数的素因子分解是乘积等于此素数的集合。
例如: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();
}
}

没看懂...

[Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解的更多相关文章

  1. [Introduction to programming in Java 笔记] 1.3.8 Gambler's ruin simulation 赌徒破产模拟

    赌徒赢得机会有多大? public class Gambler { public static void main(String[] args) { // Run T experiments that ...

  2. [Introduction to programming in Java 笔记] 1.3.7 Converting to binary 十进制到二进制的转换

    public class Binary { public static void main(String[] args) { // Print binary representation of N. ...

  3. Thinking in Java——笔记(1)

    Introduction To Obejct The progress of abstraction But their primary abstraction still requires you ...

  4. java笔记整理

    Java 笔记整理 包含内容     Unix Java 基础, 数据库(Oracle jdbc Hibernate pl/sql), web, JSP, Struts, Ajax Spring, E ...

  5. Effective Java笔记一 创建和销毁对象

    Effective Java笔记一 创建和销毁对象 第1条 考虑用静态工厂方法代替构造器 第2条 遇到多个构造器参数时要考虑用构建器 第3条 用私有构造器或者枚举类型强化Singleton属性 第4条 ...

  6. java笔记00-目录

    --2013年7月26日17:49:59 学习java已久,趁最近有空,写一个总结: java笔记01-反射:

  7. 每天一本电子书 - JavaScript for Kids: A Playful Introduction to Programming

    JavaScript for Kids: A Playful Introduction to Programming 作者: Nick Morgan  出版社: No Starch Press 副标题 ...

  8. 2018-12-09 疑似bug_中文代码示例之Programming in Scala笔记第九十章

    续前文: 中文代码示例之Programming in Scala笔记第七八章 源文档库: program-in-chinese/Programming_in_Scala_study_notes_zh ...

  9. 2018-11-27 中文代码示例之Programming in Scala笔记第七八章

    续前文: 中文代码示例之Programming in Scala学习笔记第二三章 中文代码示例之Programming in Scala笔记第四五六章. 同样仅节选有意思的例程部分作演示之用. 源文档 ...

随机推荐

  1. bat处理打开关门exe

    @echo off rem rem 注释 tastkill /f /im a.exe cd %CD% %CD:~0,1%: cd  %Cd%b start %CD%a.exe cd .. %CD:~0 ...

  2. Bzoj 1391: [Ceoi2008]order 网络流,最大权闭合图

    1391: [Ceoi2008]order Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1105  Solved: 331[Submit][Statu ...

  3. 《使用wxWidgets进行跨平台程序开发》chap02——一个简单的应用程序

    // Name: minimal.cpp // Purpose: Minimal wxWidgets sample // Author: Julian Smart #include "wx/ ...

  4. mkdir、whoami、touch

    mkdir whoami touch:"摸",如果文件不存在,就建立新文件,如果存在,就改变文件的访问时间atime等时间戳信息. mkdir aa ls –ld aa 创建多级目 ...

  5. 模仿GsonConverter 写的StringConverter 解析String字符串

    使用自己写的StringConverter 来封装的 Converter 来解析String private static final RestAdapter CAMERA_CLIENT_NETWOR ...

  6. Ajax交互demo1

    一.概念 Ajax异步请求刷新. 浏览器在用户不知道的情况下,偷偷地跟服务器交互,然后返回数据给浏览器显示. 异步过程:当HTTP请求发送后,通过Ajax技术使用的XMLHttpRequest对象来发 ...

  7. Data Types in the Kernel &lt;LDD3 学习笔记&gt;

    Data Types in the Kernel Use of Standard C Types /* * datasize.c -- print the size of common data it ...

  8. ViewPager的用法

    ViewPager 1.布局文件中的配置 ViewPager的路径 方法:在源码文件中输入ViewPager,按下alt+/,上面就会出来viewPager的包路径 viewPager的配置很简单,前 ...

  9. SCADESuite嵌入式软件基于模型的开发

    SCADE Suite®产品是针对高安全性嵌入式软件的基于模型的开发环境 SCADE Suite是高安全性嵌入式软件的开发标准,其应用领域涵盖航空.国防.轨道交通.能源和重工业.专为最高等级的质量和安 ...

  10. Shell变量命名规则

    变量与变量内容以一个等号『=』来连结,如下所示: 『myname=chenfei0801』 等号两边不能直接接空格符,如下所示为错误: 『myname = chenfei0801』或『myname=c ...