2018-2019-2 20,175,310 individual project reports intimate number 3--

2018-2019-2 20,175,310 individual project reports intimate number 3--

definition:

If aall factors being equal b, ball factors being equal a, factors including 1 but excluding itself, and anot equal b, called a,bfor the intimate number right.

demand analysis:

According to the definition of intimate numbers, it was designed and implemented in the Java language.

Design and Implementation:

Implementation of the code is less than the number of close to 10,000 output
pseudo-code as follows:

1、计算数a的各因子,各因子之和存放于b
2、计算数b的各因子,各因子之和存放于n
3、若n=a,则a和b是一对亲密数

Difficulties Summary:

Initially write code full of loopholes, above all, he did not rule out a和athat equal, the next is not a和bthere b和athis duplication delete

these two problems are solved in the same statement:

//若n=a,则a和b是一对亲密数
            if(n==a&&b!=n&&a<b) {
                System.out.println(a+"和"+b);
            }

I started to write the code if the condition statement only judge n==a, newly added b!=nis to remove a和athis case, a<bit is to remove a和bas well as b和athis duplication

Screenshot operating results:

Cloud link code

PSP time

step Consuming (min) percentage
demand analysis 10 11%
design 20 22%
Code 30 33%
test 10 11%
analysis Summary 20 22%

Guess you like

Origin www.cnblogs.com/xicyannn/p/10887486.html