Home > other >  Python 3 practice instance, subject infer that don't understand.
Python 3 practice instance, subject infer that don't understand.

Time:01-26

Topic: an integer, it combined with after 100 is a completely square, coupled with the number 168 is a completely square, what is the number, please?

Program analysis:

Assuming that the number of x,

1, : x + 100=n2, x + + 168=100 m2

2, the calculation equation: m2 - n2=(m + n) (m, n)=168

3, set up: m + n=I, m - n=j, I * j=168, I and j is at least one even

4, available: m=(I + j)/2, n=(I - j)/2, I and j are even, either or is odd,

5, from 3 and 4 can know, I and j are an even number greater than or equal to 2,

6, because I * j=168, j>=2, 1 & lt; I & lt; 168/2 + 1,

7, then will I all digital loop computations,

 
#! The/usr/bin/python
# - * - coding: utf-8 - * -

For I in range (1) 30:
If I==0 168% :
J=168/I;
If I & gt; J and (I + j) % 2==0 and (I - j) % 2==0:
M=(I + j)/2
N=(I - j)/2
X=n * n - 100
Print (x)


What eldest brother can tell me, 5 and 6 stage is inferred?
  • Related