Java calculates that a number plus 100 is a perfect square plus 168 is a perfect square

  • 2020-06-12 09:02:22
  • OfStack

1 integer, plus 100 is a perfect square, plus 168 is a perfect square, what is the number?

Program analysis: within 100,000, add the number to 100 before taking the root, and then add the number to 268 before taking the root. If the result after taking the root satisfies the following conditions, it is the result. Please refer to the specific analysis:

Program design:


public class test {
  public static void main (String[]args){
  long k=0;
  for(k=1;k<=100000l;k++)
  if(Math.floor(Math.sqrt(k+100))==Math.sqrt(k+100) && Math.floor(Math.sqrt(k+168))==Math.sqrt(k+168))
    System.out.println(k);
  }
}

Property 1: the last digit of a perfect square can only be 0,1,4,5,6,9.
Property 2: the ones digits of an odd square are odd, and the ten digits are even.
Prove that odd Numbers must be 1 of the following 5 forms:
10a+1, 10a+3, 10a+5, 10a+7, 10a+9
When you square them, you get
(10a+1)^2=100+20a+1=20a(5a+1)+1
(10a+3)^2=100+60a+9=20a(5a+3)+9
(10a+5)^2=100+100a+25=20 (5a+5a+1)+5
(10a+7)^2=100+140a+49=20 (5a+7a+2)+9
(10a+9)^2=100+180a+81=20 (5a+9a+4)+1
In conclusion, the square of an odd number and the ones digit are odd 1,5,9; Ten digits are even.
Property 3: If the 10 digits of a perfect square are odd, the ones digit 1 must be 6; Conversely, if the ones digit of a perfect square is 6, its 10-digit 1 must be odd.
Prove that we know =10k+6, prove that k is odd. Since the units digit of is 6, the units digit of m is 4 or 6, so you can set m=10n+4 or 10n+6. the
10k+6=(10n+4)=100+(8n+1)x10+6
Or 10 k + 6 = 10 n (+ 6) = 100 + x10 n (12 + 3) + 6
Namely k = 10 + 8 n + 1 = 2 (5 + 4 n) + 1
Or k n = 10 + 12 + 3 = 2 (5 + 6 n) + 3
∴ k is odd.
Corollary 1: If the 10 digits of a number are odd and the ones digit is not 6, then the number 1 must not be a perfect square.
Corollary 2: If the ones digit of a perfect square is not 6, its 10 digits are even.
Property 4: The square of an even number is a multiple of 4; The square of an odd number is a multiple of 4 plus 1.
That's because 2k+1 is equal to 4k(k+1)+1
(2k)=4
Property 5: The square of an odd number is type 8n+1; The square of the even number is type 8n or type 8n+4.
In the proof of property 4, when k(k+1)1 is even, it can be obtained that (2k+1) is the number of type 8n+1. The number (2k) of type 8n or type 8n+4 can be obtained by being odd or even.
Property 6: The form of a square must be 1:3 k,3k+1 of the following two types.
Because the natural Numbers are divided by 3, they can be divided into 3 categories by remainder: 3m,3m+1, 3m+2. If you square it, you get
(3m)=9=3k
(3m+1)=9+6m+1=3k+1
(3m+2)=9+12m+4=3k+1
Similarly, it can be obtained that:
Property 7: The square of a number not divisible by 5 is type 5k±1, and the square of a number divisible by 5 is type 5k.
Property 8: The forms of square Numbers are 1:16 m,16m+1, 16m+4, 16ES91en +9.
In addition to the above properties of the units digit, 10 digit, and remainder, we can also study the sum of the digits in a perfect square. For example, 256 its bits add up to 2+5+6=13. 13 is called the sum of the bits of 256. If you add the digits of 13:1+3= 4,4 can also be called the sum of the digits of 256. The sum of the digits of the number mentioned below means adding the digits of the number. If the sum of the digits is not 1 digit, add the digits again until they are 1 digit. We can get the following statement:
The sum of the digits of 1 is equal to the remainder of this number divided by 9.
The following is an example of a 4-digit number to illustrate this proposition.
Set the 4-digit number as, then
= 1000a+100b+10c+d
= 999a+99b+9c+(a+b+c+d)
= 9(111a+11b+c)+(a+b+c+d)
Obviously, a+b+c+d is the remainder of a 4-digit number divided by 9.
The n digit can also be proved in this way.
The sum of perfect squares has the following properties:
Property 9: the sum of perfect squares can only be 0,1,4,7,9.
Because an integer divided by 9 can only be 9k,9k±1, 9k±2, 9k±3, 9k±4, and
(9k)=9(9)+0
(9 k + 1) = 9 (9 + 2 k) + 1
k (9 + 2) = 9 (9 + 4 k) + 4
(9 k + 3) = 9 (9 + 6 k) + 9
(9 k + 4) = 9 (9 + 8 k + 1) + 7
In addition to the above, there are the following important properties:
Property 10: The necessary and sufficient condition for perfect square is that b is perfect square.
Prove sufficiency: set b as the square number, then
==(ac)
Necessity: if is a perfect square number, =, then
Property 11: If the prime number p divisible by a, but p squared not divisible by a, then a is not a perfect square.
It can be seen from the problem that a has a prime factor of p, but has no factor. It can be seen that when a is divided into standard formula, the power of p is 1, while when the perfect square number is divided into standard formula, the power of each prime factor is even, so a is not a perfect square number.
Property 12: All integers between the squares of two adjacent integers are not perfect squares, if
n^2 < k^2 < (n+1)^2
So k1 must not be a perfect square.
Property 13:1 A sufficient and necessary condition for n to be a perfect square is that n has an odd number of factors (including 1 and n itself).


Related articles: