当前位置:网站首页>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

边栏推荐
- 【云原生 | 从零开始学Kubernetes】三、Kubernetes集群管理工具kubectl
- Keil use details -- magic wand
- FIO测试硬盘性能参数和实例详细总结(附源码)
- Take you to understand the working principle of lithium battery protection board
- STM32 virtualization environment of QEMU
- 关于线性稳压器的五个设计细节
- Halcon's practice based on shape template matching [2]
- Solutions to compilation warnings in Quartus II
- OC and OD gate circuit
- MySQL MHA high availability cluster
猜你喜欢

Semiconductor devices (I) PN junction

Process communication mode between different hosts -- socket

Talk about the function of magnetic beads in circuits

Bluebridge cup internet of things basic graphic tutorial - GPIO output control LD5 on and off

实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?

The firmware of the connected j-link does not support the following memory access

Carrier period, electrical speed, carrier period variation
![[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement](/img/54/78e4e10724b2762274b06debb10877.jpg)
[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
![Halcon's practice based on shape template matching [1]](/img/68/206eed7502fbf108a929aa9365b1ae.jpg)
Halcon's practice based on shape template matching [1]

STM32 tutorial triple ADC interleaved sampling
随机推荐
Hardware 3 -- function of voltage follower
MHA High available Cluster for MySQL
Halcon's practice based on shape template matching [1]
Problem solving: interpreter error: no file or directory
[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication
Nb-iot technical summary
Step motor generates S-curve upper computer
Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
Bluetooth hc-05 pairing process and precautions
VESC Benjamin test motor parameters
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
Verilog -- state machine coding method
Synchronization of QT multithreading
WiFi wpa_ Detailed description of supplicant hostpad interface
Negative pressure generation of buck-boost circuit
剑指 Offer 09. 用两个栈实现队列
Basic information commands and functions of kernel development
实例004:这天第几天 输入某年某月某日,判断这一天是这一年的第几天?
STM32---IIC