一个非零自然数n满足n+2022之间(包括n和n+2022)恰有22个完全平方...

发布网友 发布时间:2024-10-23 22:47

我来回答

1个回答

热心网友 时间:2天前

第一步,先确定 n 所在区间:

n 到 (n+2022) 之间的完全平方数个数,大约为 (n+2022)^0.5-n^0.5+1

因此,有估算方程,(n+2022)^0.5-n^0.5+1 = 22

(n+2022)^0.5 = 21+n^0.5

n+2022 = 21^2+42*n^0.5+n

2022-21^2 = 42*n^0.5

527 = 14*n^0.5

n = (527/14)^2 = 1416(是个估算值,取整)

第二步,验算结果:

n^0.5 = 1416^0.5 = 37.6 = 38,区间下端,进一法取整

(n+2022)^0.5 = (1416+2022)^0.5 = 58.6 = 58,区间上端,去尾法取整

区间内的完全平方数个数,58-38+1 = 21个 < 22个

正整数越大,完全平方数的分布越稀疏

因此,n < 1416

第三步,通过试算确定 n 的值:

可以手工计算,但是工作量有点大

因此,写了一段 fortran 代码

试算结果,n 有 190 个解,具体如下:

1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1367,1368,

total = 190

~~~~~~~~~~~~~~~~~~~~~~~~~

说明:

n 的这些值是不连续的。原因是,对于某些 n,n 到 (n+2022) 恰好会多纳进一个完全平方数,变成 23 个;而对于 n = 1340,则会少纳进一个完全平方数,变成 21 个。

例如 n = 1115 时,区间是 1115 到 3137,最小的完全平方数是 34,最大的完全平方数是 56,一共有 56-34+1 = 23 个。

因此,通过区间来确定 n 的具体值是不可行的。只能通过逐个试算来确定,别无他法。

~~~~~~~~~~~~~~~~~~~~~~~~~

附:fortran代码

do i=1,1416

   k1=sqrt(dble(i))+1

   k2=sqrt(2022d0+i)

   if(k2-k1+1.ne.22) cycle

   m=m+1

   write(*,'(i4,a\)') i,','

end do

write(*,'(/a,i3)') 'total = ',m

end

热心网友 时间:2天前

第一步,先确定 n 所在区间:

n 到 (n+2022) 之间的完全平方数个数,大约为 (n+2022)^0.5-n^0.5+1

因此,有估算方程,(n+2022)^0.5-n^0.5+1 = 22

(n+2022)^0.5 = 21+n^0.5

n+2022 = 21^2+42*n^0.5+n

2022-21^2 = 42*n^0.5

527 = 14*n^0.5

n = (527/14)^2 = 1416(是个估算值,取整)

第二步,验算结果:

n^0.5 = 1416^0.5 = 37.6 = 38,区间下端,进一法取整

(n+2022)^0.5 = (1416+2022)^0.5 = 58.6 = 58,区间上端,去尾法取整

区间内的完全平方数个数,58-38+1 = 21个 < 22个

正整数越大,完全平方数的分布越稀疏

因此,n < 1416

第三步,通过试算确定 n 的值:

可以手工计算,但是工作量有点大

因此,写了一段 fortran 代码

试算结果,n 有 190 个解,具体如下:

1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1367,1368,

total = 190

~~~~~~~~~~~~~~~~~~~~~~~~~

说明:

n 的这些值是不连续的。原因是,对于某些 n,n 到 (n+2022) 恰好会多纳进一个完全平方数,变成 23 个;而对于 n = 1340,则会少纳进一个完全平方数,变成 21 个。

例如 n = 1115 时,区间是 1115 到 3137,最小的完全平方数是 34,最大的完全平方数是 56,一共有 56-34+1 = 23 个。

因此,通过区间来确定 n 的具体值是不可行的。只能通过逐个试算来确定,别无他法。

~~~~~~~~~~~~~~~~~~~~~~~~~

附:fortran代码

do i=1,1416

   k1=sqrt(dble(i))+1

   k2=sqrt(2022d0+i)

   if(k2-k1+1.ne.22) cycle

   m=m+1

   write(*,'(i4,a\)') i,','

end do

write(*,'(/a,i3)') 'total = ',m

end

声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com