当前位置:网站首页>Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
2022-07-05 08:21:00 【Lazy smile】
example 003: Complete square
subject : An integer , It adds 100 And then there's a complete square , Plus 168 It's a complete square again , What is the number ?
Program analysis : because 168 It's too small for an exponential explosion , Therefore, mathematical analysis can be omitted directly , Use the simplest way to get the upper limit ,
n = 0
while (n + 1) ** 2 - n * n <= 168:
n += 1
print('----n=', n) # It can be concluded that the range is (n+1)**2 Inside The train of thought is :
The worst result is n The sum of the squares of (n+1) The square of is just the difference 168, Because it's Square , There can be no greater gap than this .
Let this number be i (i+100)**0.5 (i+100+168)**0.5 Then the results are all integers .
As for judging whether it is a complete square number , The easiest way is : The value of the square root is decimal 0 that will do .
for i in range((n + 1) ** 2):
if i ** 0.5 == int(i ** 0.5) and (i + 168) ** 0.5 == int((i + 168) ** 0.5):
print(i - 100)The combination is :
# The worst result is n The sum of the squares of (n+1) The square of is just the difference 168, There can be no greater gap than this , Based on this, we come to the conclusion that n
n = 0
while (n + 1) ** 2 - n * n <= 168:
n += 1
print('----n=', n) # It can be concluded that the range is (n+1)**2 Inside
for i in range((n + 1) ** 2):
if i ** 0.5 == int(i ** 0.5) and (i + 168) ** 0.5 == int((i + 168) ** 0.5):
print(i - 100)------n= 84
-99
21
261
1581Therefore, the number can be :-99 21 61 1581

边栏推荐
- Solutions to compilation warnings in Quartus II
- Keil use details -- magic wand
- Step motor generates S-curve upper computer
- Wifi-802.11 negotiation rate table
- NTC thermistor application - temperature measurement
- Adaptive filter
- 实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.
- matlab timeserise
- STM32---ADC
- 亿学学堂给的证券账户安不安全?哪里可以开户
猜你喜欢

Design a clock frequency division circuit that can be switched arbitrarily
![C WinForm [get file path -- traverse folder pictures] - practical exercise 6](/img/8b/1e470de4e4ecd4fd1bb8e5cf23f466.jpg)
C WinForm [get file path -- traverse folder pictures] - practical exercise 6

Array integration initialization (C language)

How to copy formatted notepad++ text?

Introduction of air gap, etc

Process communication mode between different hosts -- socket

Keil use details -- magic wand
![[paper reading] the latest transfer ability in deep learning: a survey in 2022](/img/6b/b564fb7a6895329073fb5eaff64340.png)
[paper reading] the latest transfer ability in deep learning: a survey in 2022

STM32 single chip microcomputer - bit band operation
![Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev](/img/42/d857452ccfeccbbf1ac34f47e47e2e.jpg)
Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
随机推荐
UE像素流,来颗“减肥药”吧!
如何写Cover Letter?
2020-05-21
Naming rules for FreeRTOS
My-basic application 1: introduction to my-basic parser
C # joint configuration with Halcon
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
剑指 Offer 06. 从尾到头打印链表
Volatile of C language
List of linked lists
Explain task scheduling based on Cortex-M3 in detail (Part 2)
[tutorial 19 of trio basic from introduction to proficiency] detailed introduction of trio as a slave station connecting to the third-party bus (anybus PROFIBUS DP...)
Wifi-802.11 negotiation rate table
Tailq of linked list
Classic application of MOS transistor circuit design (1) -iic bidirectional level shift
Simple design description of MIC circuit of ECM mobile phone
STM32 single chip microcomputer - bit band operation
[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication
实例010:给人看的时间
实例002:“个税计算” 企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.