VB循環(huán)程序例題100道附答案_第1頁(yè)
VB循環(huán)程序例題100道附答案_第2頁(yè)
VB循環(huán)程序例題100道附答案_第3頁(yè)
VB循環(huán)程序例題100道附答案_第4頁(yè)
VB循環(huán)程序例題100道附答案_第5頁(yè)
已閱讀5頁(yè),還剩26頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、VB循環(huán)程序例題附答案 1.素?cái)?shù)1. 100,999范圍內(nèi)同時(shí)滿足以下兩個(gè)條件的十進(jìn)制數(shù). 其個(gè)位數(shù)字與十位數(shù)字之和除以10所得的余數(shù)是百位數(shù)字;該數(shù)是素?cái)?shù); 求有多少個(gè)這樣的數(shù)? 15n = 0For i = 100 To 999a = i 100b = i 10 Mod 10c = i Mod 10If (c + b) Mod 10 = a Then x = 0 For j = 2 To i - 1 If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then n = n + 1End IfNext iPrint n2. 300,800范

2、圍內(nèi)同時(shí)滿足以下兩個(gè)條件的十進(jìn)制數(shù). 其個(gè)位數(shù)字與十位數(shù)字之和除以10所得的余數(shù)是百位數(shù)字 ;該數(shù)是素?cái)?shù);求滿足上述條件的最大的三位十進(jìn)制數(shù)。761For i = 300 To 800a = i 100b = i 10 Mod 10c = i Mod 10If (c + b) Mod 10 = a Then x = 0 For j = 2 To i - 1 If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then s = iEnd IfNext iPrint s3. 除1和它本身外,不能被其它整數(shù)整除的正整數(shù)稱為素?cái)?shù)(注:1不是素?cái)?shù),2是

3、素?cái)?shù))。若兩素?cái)?shù)之差為2 ,則稱兩素?cái)?shù)為雙胞胎數(shù),問(wèn)31,601之間有多少對(duì)雙胞胎數(shù)。22n = 0For i = 31 To 601 - 2 x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 For j = 2 To Sqr(i + 2) If (i + 2) Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then n = n + 1 End IfNext iPrint n4.數(shù)學(xué)家哥德巴赫曾猜測(cè):任何大于6的偶數(shù)都可

4、以分解成兩個(gè)素?cái)?shù)(素?cái)?shù)對(duì))的和。但有些偶數(shù)可以分解成多種素?cái)?shù)對(duì)的和,如: 10=3+7,10=5+5,即10可以分解成兩種不同的素?cái)?shù)對(duì)。試求6744可以分解成多少種不同的素?cái)?shù)對(duì)(注: A+B與B+A認(rèn)為是相同素?cái)?shù)對(duì))144n = 0For i = 2 To 6744 / 2 x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 For j = 2 To Sqr(6744 - i) If (6744 - i) Mod j = 0 Then y = 1: Exit For N

5、ext j If y = 0 Then n = n + 1 End IfNext iPrint n5. 兩個(gè)素?cái)?shù)之差為2,則稱這兩個(gè)素?cái)?shù)為雙胞胎數(shù)。求出200,1000之間的最大一對(duì)雙胞胎數(shù)的和。1764For i = 200 To 1000 - 2 x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 For j = 2 To Sqr(i + 2) If (i + 2) Mod j = 0 Then y = 1: Exit For Next j If y = 0 The

6、n s = i + i + 2 End IfNext iPrint s6. 一個(gè)素?cái)?shù)(設(shè)為p)依次從最高位去掉一位,二位,三位,若得到的各數(shù)仍都是素?cái)?shù)(注:除1和它本身外,不能被其它整數(shù)整除的正整數(shù)稱為素?cái)?shù),1不是素?cái)?shù),2是素?cái)?shù)),且數(shù)p的各位數(shù)字均不為零,則稱該數(shù)p為逆向超級(jí)素?cái)?shù)。例如,617,17,7都是素?cái)?shù),因此617是逆向超級(jí)素?cái)?shù),盡管503,03,3都是素?cái)?shù),但它不是逆向超級(jí)素?cái)?shù),因?yàn)樗辛?。試?00,999之內(nèi)的所有逆向超級(jí)素?cái)?shù)的個(gè)數(shù)。 39n = 0For i = 100 To 999 a = i 10 Mod 10 b = i Mod 10 If a <> 0

7、 And b <> 0 And b <> 1 Then x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 c = i Mod 100 For j = 2 To Sqr(c) If c Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then z = 0 For j = 2 To Sqr(b) If b Mod j = 0 Then z = 1: Exit For Next j If z = 0 Th

8、en n = n + 1 End If End If End IfNext iPrint n7.德國(guó)數(shù)學(xué)家哥德巴赫曾猜測(cè):任何大于6的偶數(shù)都可以分解成兩個(gè)素?cái)?shù)(素?cái)?shù)對(duì))的和。但有些偶數(shù)可以分解成多種素?cái)?shù)對(duì)的和,如: 10=3+7,10=5+5,即10可以分解成兩種不同的素?cái)?shù)對(duì)。試求1234可以分解成多少種不同的素?cái)?shù)對(duì)(注: A+B與B+A認(rèn)為是相同素?cái)?shù)對(duì))25n = 0For i = 2 To 1234 / 2 x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 For

9、 j = 2 To Sqr(1234 - i) If (1234 - i) Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then n = n + 1 End IfNext iPrint n8.求100,900之間相差為12的素?cái)?shù)對(duì)(注:要求素?cái)?shù)對(duì)的兩個(gè)素?cái)?shù)均在該范圍內(nèi))的個(gè)數(shù)。50n = 0For i = 100 To 900 - 12 x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 For j = 2 To Sqr

10、(i + 12) If (i + 12) Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then n = n + 1 End IfNext iPrint n9.一個(gè)素?cái)?shù)(設(shè)為p)依次從最高位去掉一位,二位,三位,若得到的各數(shù)仍都是素?cái)?shù)(注:1不是素?cái)?shù)),且數(shù)p的各位數(shù)字均不為零,則稱該數(shù)p為逆向超級(jí)素?cái)?shù)。例如,617,17,7都是素?cái)?shù),因此617是逆向超級(jí)素?cái)?shù),但盡管503,03,3都是素?cái)?shù),但它不是逆向超級(jí)素?cái)?shù),因?yàn)樗辛?。試?00,999之內(nèi)的所有逆向超級(jí)素?cái)?shù)的和。21645s = 0For i = 100 To 999 a = i 1

11、0 Mod 10 b = i Mod 10 If a <> 0 And b <> 0 And b <> 1 Then x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 c = i Mod 100 For j = 2 To Sqr(c) If c Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then z = 0 For j = 2 To Sqr(b) If b Mod j = 0 Th

12、en z = 1: Exit For Next j If z = 0 Then s = s + i End If End If End IfNext iPrint s10.一個(gè)素?cái)?shù)(設(shè)為p)依次從最高位去掉一位,二位,三位,若得到的各數(shù)仍都是素?cái)?shù)(注:1不是素?cái)?shù),2是素?cái)?shù)),且數(shù)p的各位數(shù)字均不為零,則稱該數(shù)p為逆向超級(jí)素?cái)?shù)。例如,617,17,7都是素?cái)?shù),因此617是逆向超級(jí)素?cái)?shù),但盡管503,03,3都是素?cái)?shù),但它不是逆向超級(jí)素?cái)?shù),因?yàn)樗辛恪T嚽?00,999之內(nèi)的所有逆向超級(jí)素?cái)?shù)從大到小數(shù)的第10個(gè)素?cái)?shù)是多少?797n = 0For i = 999 To 100 Step -1 a

13、 = i 10 Mod 10 b = i Mod 10 If a <> 0 And b <> 0 And b <> 1 Then x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 c = i Mod 100 For j = 2 To Sqr(c) If c Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then z = 0 For j = 2 To Sqr(b) If b Mod j

14、= 0 Then z = 1: Exit For Next j If z = 0 Then n = n + 1: If n = 10 Then s = i End If End If End IfNext iPrint s11.一個(gè)自然數(shù)是素?cái)?shù),且它的數(shù)字位置經(jīng)過(guò)任意對(duì)換后仍為素?cái)?shù),則稱為絕對(duì)素?cái)?shù)。如13,試求所有兩位絕對(duì)素?cái)?shù)的和。429s = 0For i = 10 To 99 a = i 10 b = i Mod 10 x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y =

15、 0 c = b * 10 + a For j = 2 To Sqr(c) If c Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then s = s + i End IfNext iPrint s12.在200,900范圍 內(nèi)同時(shí)滿足以下兩個(gè)條件的十進(jìn)制數(shù):其個(gè)位數(shù)字與十位數(shù)字之和除以10所得的余數(shù)是百位數(shù)字; 該數(shù)是素?cái)?shù);問(wèn)有多少個(gè)這樣的數(shù)?14n = 0For i = 200 To 900a = i 100b = i 10 Mod 10c = i Mod 10If (c + b) Mod 10 = a Then x = 0 For j =

16、 2 To i - 1 If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then n = n + 1End IfNext iPrint n13.一個(gè)素?cái)?shù),依次從個(gè)位開始去掉一位,二位.,所得的各數(shù)仍然是素?cái)?shù),稱為超級(jí)素?cái)?shù)。求100,999之內(nèi)超級(jí)素?cái)?shù)的個(gè)數(shù)。14n = 0For i = 100 To 999 x = 0 For j = 2 To Sqr(i) If i Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then a = i 10 y = 0 For j = 2 To Sqr(a)

17、 If a Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then b = i 100 If b <> 1 Then z = 0 For j = 2 To Sqr(b) If b Mod j = 0 Then z = 1: Exit For Next j If z = 0 Then n = n + 1 End If End If End IfNext iPrint n14. 若兩個(gè)連續(xù)的自然數(shù)的乘積減1后是素?cái)?shù),則稱此兩個(gè)連續(xù)自然數(shù)為友數(shù)對(duì),該素?cái)?shù)稱為友素?cái)?shù)。例如,由于 8*9-1=71, 因此,8與9是友素?cái)?shù)對(duì),71是友素?cái)?shù)。求10

18、0,200之間的第10個(gè)友素?cái)?shù)對(duì)所對(duì)應(yīng)的友素?cái)?shù)的值(按由小到大排列)。17291For i = 100 To 199 a = i * (i + 1) - 1 x = 0 For j = 2 To Sqr(a) If a Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then n = n + 1 If n = 10 Then s = a End IfNext iPrint s15.求2,400中相差為10的相鄰素?cái)?shù)對(duì)(兩數(shù)中間沒(méi)有其它素?cái)?shù))的對(duì)數(shù)。5n = 0For I = 2 To 400 - 10 x = 0 For j = 2 To Sqr(

19、I) If I Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then y = 0 For j = 2 To Sqr(I + 10) If (I + 10) Mod j = 0 Then y = 1: Exit For Next j If y = 0 Then For k = I + 1 To I + 9 z = 0 For k1 = 2 To Sqr(k) If k Mod k1 = 0 Then z = 1: Exit For Next k1 If z = 0 Then Exit For Next k If k = I + 10 Then n

20、 = n + 1 End If End IfNext IPrint n16.若兩個(gè)連續(xù)的自然數(shù)的乘積減1后是素?cái)?shù),則稱此兩個(gè)連續(xù)自然數(shù)為友數(shù)對(duì),該素?cái)?shù)稱為友素?cái)?shù)。例如,由于 8*9-1=71, 因此,8與9是友數(shù)對(duì),71是友素?cái)?shù)。求50,150之間的友數(shù)對(duì)的數(shù)目。38n = 0For i = 50 To 150 a = i * (i + 1) - 1 x = 0 For j = 2 To Sqr(a) If a Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then n = n + 1 End IfNext iPrint n17. 若兩個(gè)連續(xù)自然

21、數(shù)乘積減1后是素?cái)?shù),則稱此兩個(gè)自然連續(xù)數(shù)為友數(shù)對(duì),該素?cái)?shù)稱為友素?cái)?shù),例:2*3-1=5,因此2與3是友數(shù)對(duì),5是友素?cái)?shù),求40,119之間友素?cái)?shù)對(duì)的數(shù)目。30n = 0For i = 40 To 119 a = i * (i + 1) - 1 x = 0 For j = 2 To Sqr(a) If a Mod j = 0 Then x = 1: Exit For Next j If x = 0 Then n = n + 1 End IfNext iPrint n18.梅森尼數(shù)是指能使2n-1為素?cái)?shù)的數(shù)n,求1,21范圍內(nèi)有多少個(gè)梅森尼數(shù)?7n = 0For i = 2 To 21 x = 2

22、 i - 1 k = 0 For j = 2 To Sqr(x) If x Mod j = 0 Then k = 1 Next j If k = 0 Then n = n + 1Next iPrint n19. 300,800范圍內(nèi)同時(shí)滿足以下兩個(gè)條件的十進(jìn)制數(shù). 其個(gè)位數(shù)字與十位數(shù)字之和除以10所得的余數(shù)是百位數(shù)字 ;該數(shù)是素?cái)?shù);求滿足上述條件的最大的三位十進(jìn)制數(shù)。761For i = 300 To 800 a = i 100 b = i 10 Mod 10 c = i Mod 10 If (c + b) Mod 10 = a Then k = 0 For j = 2 To Sqr(i) I

23、f i Mod j = 0 Then k = 1 Next j If k = 0 Then s = i End IfNext iPrint s 2. 取數(shù)字20. 求符合下列條件的四位完全平方數(shù)(某個(gè)正整數(shù)A是另一個(gè)正整數(shù)B的平方,則稱A為完全平方數(shù)),它的千位數(shù)字與十位數(shù)字之和等于百位數(shù)字與個(gè)位數(shù)字之積,例如,3136=562, 且3+3=1*6 故3136是所求的四位完全平方數(shù). 求其中最大的一個(gè)數(shù)。7921For i = 1000 To 9999 x = Sqr(i) If x = Int(x) Then a = i 1000 b = i 100 Mod 10 c = i 10 Mod

24、10 d = i Mod 10 If (a + c) = b * d Then s = i End IfNext iPrint s21.設(shè)某四位數(shù)的千位數(shù)字平方與十位數(shù)字的平方之和等于百位數(shù)字的立方與個(gè)位數(shù)字的立方之和,例如,對(duì)于四位數(shù):3201, 32+02=23+13,試問(wèn)所有這樣的四位數(shù)之和是多少?97993s = 0For i = 1000 To 9999 a = i 1000 b = i 100 Mod 10 c = i 10 Mod 10 d = i Mod 10 If (a 2 + c 2) = b 3 + d 3 Then s = s + iNext iPrint s22. 設(shè)

25、某四位數(shù)的千位數(shù)字與十位數(shù)字的和等于百位數(shù)字與個(gè)位數(shù)字的積,例如,對(duì)于四位數(shù):9512,9+1=5*2,試問(wèn)所有這樣的四位數(shù)之和是多少?1078289s = 0For i = 1000 To 9999 a = i 1000 b = i 100 Mod 10 c = i 10 Mod 10 d = i Mod 10 If (a + c) = b * d Then s = s + iNext iPrint s23.有一個(gè)三位數(shù)滿足下列條件: (1)此三位數(shù)的三位數(shù)字各不相同; (2)此三位數(shù)等于它的各位數(shù)字的立方和。試求所有這樣的三位數(shù)之和。1301s = 0For i = 100 To 999

26、a = i 100 b = i 10 Mod 10 c = i Mod 10 If (a 3 + b 3 + c 3) = i And a <> b And b <> c And c <> a Then s = s + iNext iPrint s24. 求1,999之間能被3整除,且至少有一位數(shù)字是5的所有正整數(shù)的個(gè)數(shù)。91n = 0For i = 1 To 999 a = i 100 b = i 10 Mod 10 c = i Mod 10 If i Mod 3 = 0 And (a = 5 Or b = 5 Or c = 5) Then n = n +

27、 1Next iPrint n25. 有一個(gè)三位數(shù)滿足下列條件: (1)此三位數(shù)的三位數(shù)字各不相同; (2)此三位數(shù)等于它的各位數(shù)字的立方和。試求所有這樣的三位數(shù)中最大的一個(gè)是多少? 407s = 0For i = 100 To 999 a = i 100 b = i 10 Mod 10 c = i Mod 10 If (a 3 + b 3 + c 3) = i And a <> b And b <> c And c <> a Then s = iNext iPrint s26. 有一個(gè)三位數(shù)滿足下列條件: (1)此三位數(shù)的三位數(shù)字各不相同; (2)此三位數(shù)

28、等于它的各位數(shù)字的立方和。試求這種三位數(shù)共有多少個(gè)? 4n = 0For i = 100 To 999 a = i 100 b = i 10 Mod 10 c = i Mod 10 If (a 3 + b 3 + c 3) = i And a <> b And b <> c And c <> a Then n = n + 1Next iPrint n27.求五位數(shù)各位數(shù)字的平方和為100的最大的五位數(shù)。94111For i = 10000 To 99999 a = i 10000 b = i 1000 Mod 10 c = i 100 Mod 10 d =

29、i 10 Mod 10 e = i Mod 10 If a 2 + b 2 + c 2 + d 2 + e 2 = 100 Then s = iNext iPrint s28.所謂“水仙花數(shù)”是指一個(gè)三位數(shù),其各位數(shù)字的三次方之和等于該數(shù)本身,例如:153=13+33+53,故153是水仙花數(shù),求100,999之間所有水仙花數(shù)之和。1301s = 0For i = 100 To 999 a = i 100 b = i 10 Mod 10 c = i Mod 10 If (a 3 + b 3 + c 3) = i Then s = s + iNext iPrint s29. 設(shè)某四位數(shù)的各位數(shù)字

30、的平方和等于100,問(wèn)共有多少個(gè)這種四位數(shù)?49n = 0For i = 1000 To 9999 a = i 1000 b = i 100 Mod 10 c = i 10 Mod 10 d = i Mod 10 If a 2 + b 2 + c 2 + d 2 = 100 Then n = n + 1Next iPrint n30. 回文數(shù)是指正讀和反讀都一樣的正整數(shù)。例如3773是回文數(shù)。求出1000,9999以內(nèi)的所有回文數(shù)的個(gè)數(shù)。90n = 0For i = 1000 To 9999 a = i 1000 b = i 100 Mod 10 c = i 10 Mod 10 d = i M

31、od 10 If a + b * 10 + c * 100 + d * 1000 = i Then n = n + 1Next iPrint n 3. 分硬幣31. 把一張一元鈔票,換成一分、二分和五分硬幣,每種至少8枚,問(wèn)有多少種方案?80n = 0For i = 8 To 100 For j = 8 To 50 For k = 8 To 20 If (i + 2 * j + 5 * k = 100) Then n = n + 1Next k, j, iPrint n32.50元的整幣兌換成5元、2元和1元幣值(三種幣值均有、缺少一種或兩種都計(jì)算在內(nèi))的方法有多少種。146n = 0For

32、i = 0 To 50 For j = 0 To 25 For k = 0 To 10 If (i + 2 * j + 5 * k = 50) Then n = n + 1Next k, j, iPrint n33.50元的整幣兌換成5元、2元和1元幣值(要求三種幣值均有)的方法有多少種。106n = 0For i = 1 To 50 For j = 1 To 25 For k = 1 To 10 If (i + 2 * j + 5 * k = 50) Then n = n + 1Next k, j, iPrint n34. 馬克思曾經(jīng)做過(guò)這樣一道趣味數(shù)學(xué)題:有30個(gè)人在一家小飯店里用餐,其中

33、有男人、女人和小孩,每個(gè)男人花了3先令,每個(gè)女人花了2先令,每個(gè)小孩花了1先令,共花去50先令。如果要求男人、女人和小孩都有人參與,試求有多少種方案分配男人、女人和小孩的人數(shù)。9n = 0For i = 1 To 50 For j = 1 To 25 k = 30 - i - j If (i + 2 * j + 3 * k = 50) And k > 0 Then n = n + 1Next j, iPrint n 4. 勾股、弦數(shù)35. A,B,C是三個(gè)小于或等于100正整數(shù),當(dāng)滿足1/A2+1/B2=1/C2關(guān)系時(shí),稱為倒勾股數(shù)。求130<A+B+C<150且A>B

34、>C的倒勾股數(shù)有多少組。1For c = 1 To 100 For b = c + 1 To 100 For a = b + 1 To 100 i = a + b + c If (i > 100 And i < 150 And (1 / (a * a) + 1 / (b * b) = 1 / (c * c) Then n = n + 1 Print a, b, c End IfNext a, b, cPrint n36. 倒勾股數(shù)是滿足公式: 1/A2+1/B2=1/C2 的一組正整數(shù)(A,B,C),例如,(156,65,60)是倒勾股數(shù),因?yàn)椋?/1562+1/652=1/

35、602。假定A>B>C,求A,B,C之和小于100的倒勾股數(shù)有多少組? 2For c = 1 To 100 For b = c + 1 To 100 For a = b + 1 To 100 i = a + b + c If (i < 100 And (1 / (a * a) + 1 / (b * b) = 1 / (c * c) Then n = n + 1 Print a, b, c End IfNext a, b, cPrint n37. 勾股弦數(shù)是滿足公式: A2+B2=C2 (假定A<B<C)的一組正整數(shù)(A,B,C),例如,(3,4,5)是勾股弦數(shù),因

36、為:32+42=52。求A,B均小于25且A+B+C<=100的勾股弦數(shù)的個(gè)數(shù)。 11n = 0For c = 1 To 100For a = 1 To 24For b = a + 1 To 24s = a + b + cIf a 2 + b 2 = c 2 And s <= 100 Then n = n + 1Next b, a, cPrint n38.倒勾股數(shù)是滿足公式: 1/A2+1/B2=1/C2 的一組正整數(shù)(A,B,C),例如,(156,65,60)是倒勾股數(shù),因?yàn)椋?/1562+1/652=1/602。假定A>B>C,求A,B,C均小于或等于100的倒勾股

37、數(shù)有多少組?5For c = 1 To 100 For b = c + 1 To 100 For a = b + 1 To 100 i = a + b + c If 1 / (a * a) + 1 / (b * b) = 1 / (c * c) Then n = n + 1 Print a, b, c End IfNext a, b, cPrint n39.勾股弦數(shù)是滿足公式: A2+B2=C2 (假定A<B<C)的一組正整數(shù)(A,B,C),例如,(3,4,5)是勾股弦數(shù),因?yàn)椋?2+42=52。求A,B,C均小于或等于100的勾股弦數(shù)中A+B+C的最大值。240Max = 0Fo

38、r a = 1 To 100For b = a + 1 To 100For c = b + 1 To 100s = a + b + cIf a 2 + b 2 = c 2 And s > Max Then Max = sNext c, b, aPrint Max40 若某整數(shù)平方等于某兩個(gè)正整數(shù)平方之和的正整數(shù)稱為弦數(shù)。例如:由于32+42=52,則5為弦數(shù),求100,200之間弦數(shù)的個(gè)數(shù)。77n = 0For k = 100 To 200For i = 1 To kFor j = i + 1 To kIf i 2 + j 2 = k 2 Then n = n + 1Next j, i,

39、 kPrint n41若某正整數(shù)平方等于某兩個(gè)正整數(shù)平方之和,稱該正整數(shù)為弦數(shù)。例如:由于32+42=52,則5為弦數(shù),求131,200之間最小的弦數(shù)。135For k = 131 To 200For i = 1 To kFor j = i + 1 To kIf i 2 + j 2 = k 2 Then GoTo 10Next j, i, k10Print k 5.完數(shù)因子42 求在10,1000之間的所有完數(shù)之和。各真因子之和(不包括自身)等于其本身的正整數(shù)稱為完數(shù)。例如:6=1+2+3,6是完數(shù)。524Sum = 0For m = 10 To 1000 s = 0 For i = 1 To

40、 m - 1 If m Mod i = 0 Then s = s + i Next iIf s = m Then Sum = Sum + mNext mPrint Sum43 一個(gè)數(shù)如果恰好等于它的所有真因子之和,這個(gè)數(shù)就稱為“完數(shù)”。例如, 6的真因子為1,2,3,而6=1+2+3,因此,6是“完數(shù)”。求1,1000之間的最大完數(shù)。496Sum = 0For m = 1 To 1000 s = 0 For i = 1 To m - 1 If m Mod i = 0 Then s = s + i Next i If s = m Then Sum = mNext mPrint Sum44 一個(gè)數(shù)

41、如果恰好等于它的所有真因子之和,這個(gè)數(shù)就稱為“完數(shù)”。例如,6的真因子為1,2,3,而6=1+2+3,因此,6是“完數(shù)”。求1,1000之間的第二大完數(shù)。28Sum = 0For m = 1 To 1000 s = 0 For i = 1 To m - 1 If m Mod i = 0 Then s = s + i Next i If s = m Then n = n + 1 If n = 2 Then Sum = m: Exit ForNext mPrint Sum45 一個(gè)數(shù)如果恰好等于它的所有真因子之和,這個(gè)數(shù)就稱為“完數(shù)”。例如,6的真因子為1,2,3,而6=1+2+3,因此,6是“完

42、數(shù)”。求1000以內(nèi)的所有完數(shù)之和。530Sum = 0For m = 1 To 1000 s = 0 For i = 1 To m - 1 If m Mod i = 0 Then s = s + i Next i If s = m Then Sum = Sum + mNext mPrint Sum46 求200,300之間有奇數(shù)個(gè)不同因子的最大的整數(shù)(在計(jì)算因子個(gè)數(shù)時(shí),包括該數(shù)本身)。289For m = 200 To 300 k = 0 For i = 1 To m If m Mod i = 0 Then k = k + 1 Next i If k Mod 2 <> 0 The

43、n A = mNext mPrint A47求200,300之間第二大有奇數(shù)個(gè)不同因子的整數(shù)(在計(jì)算因子個(gè)數(shù)時(shí),包括該數(shù)本身)。256n = 0For m = 200 To 300 k = 0 For i = 1 To m If m Mod i = 0 Then k = k + 1 Next i If k Mod 2 <> 0 Then n = n + 1 If n = 2 Then A = m: Exit ForNext mPrint A48已知24有8個(gè)正整數(shù)因子(即:1,2,3,4,6,8,12,24),而24正好能被其因子數(shù)8整除,求正整數(shù)10,100之間有多少個(gè)正整數(shù)能被

44、其因子的個(gè)數(shù)整除。12n = 0For m = 10 To 100 k = 0 For i = 1 To m If m Mod i = 0 Then k = k + 1 Next i If m Mod k = 0 Then n = n + 1Next mPrint n 6.(數(shù)列)四舍五入49 當(dāng)m的值為50時(shí),計(jì)算下列公式的值: T=1-1/2-1/3-1/4-1/m要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第四位。-2.4992t = 1For i = 2 To 50t = t - 1 / iNext iPrint Round(t, 4)50 當(dāng)m的值為50時(shí),計(jì)算下列公式之值: t=1+1/2

45、2+1/32+1/m2(按四舍五入的方式精確到小數(shù)點(diǎn)后第四位)。1.6251t = 0For i = 1 To 50t = t + 1 / i 2Next iPrint Round(t, 4)51 當(dāng)n=100時(shí),計(jì)算S=(1-1/2)+(1/3-1/4)+(1/(2n-1)-1/(2n)的值。.要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第三位。0.691s = 0For i = 1 To 100s = s + (1 / (2 * i - 1) - 1 / (2 * i)Next iPrint Round(s, 3)52 當(dāng)n的值為25時(shí),計(jì)算下列公式的值: s=1+1/1!+1/2!+1/3!+1

46、/n!要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第四位。2.7183s = 1t = 1For i = 1 To 50t = t * is = s + 1 / tNext iPrint Round(s, 4)53 利用格里高利公式:/4=1-1/3+1/5-1/7+1/9-1/11+-1/99,求的值。要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第二位。3.12s = 0a = 1For i = 1 To 99 Step 2 s = s + 1 / i * a a = -aNext iPrint Round(s * 4, 2)54 求1/(1*2)+1/(2*3)+1/(3*4)+.+1/(N*(N+1)的

47、值,N=20, 要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第二位。0.95s = 0For i = 1 To 20 s = s + 1 / (i * (i + 1)Next iPrint Round(s, 2)55 求500以內(nèi)(含500)能被5或9整除的所有自然數(shù)的倒數(shù)之和。按四舍五入的方式精確到小數(shù)點(diǎn)后第二位。1.48s = 0For i = 1 To 500 If i Mod 5 = 0 Or i Mod 9 = 0 Then s = s + 1 / i End IfNext iPrint Round(s, 2)56 求S=1/2+2/3+3/5+5/8+的前30項(xiàng)的和(注:該級(jí)數(shù)從第二項(xiàng)開始

48、,其分子是前一項(xiàng)的分母,其分母是前一項(xiàng)的分子與分母的和)。要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第二位。18.46s = 0a = 1b = 2For i = 1 To 30 s = s + a / b t = a a = b b = t + bNext iPrint Round(s, 2)57 設(shè)S(n)=1-1/3+1/5-1/7+1/(2n-1),求S(100)的值,要求S(100)按四舍五入方式精確到小數(shù)點(diǎn)后4位。0.7829s = 0a = 1For i = 1 To 100 s = s + 1 / (2 * i - 1) * a a = -aNext iPrint Round(s,

49、4)58當(dāng)n=50時(shí),求下列級(jí)數(shù)和:S=1/(1*2)+1/(2*3)+1/(n*(n+1)要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第四位。0.9804s = 0For i = 1 To 50 s = s + 1 / (i * (i + 1)Next iPrint Round(s, 4)59計(jì)算y=1+2/3+3/5+4/7+n/(2*n-1)的值, n=50, 要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第二位。26.47s = 0For i = 1 To 50 s = s + i / (2 * i - 1)Next iPrint Round(s, 2)60計(jì)算Y=X/1!-X3/3!+X5/5!-X7/7!+前20項(xiàng)的值(已知:X=2)。要求:按四舍五入的方式精確到小數(shù)點(diǎn)后第二位。0.91s = 0x = 2a = 1t = 1For i = 1 To 20 * 2 + 1 t = t * i If i Mod 2 <> 0 Then s = s + x i / t * a a = -a End IfNext iPrint Round(s, 2)61求數(shù)列:2/1,3/2,5/3,8/5,13/8,21/13, 前50項(xiàng)之和(注:此數(shù)列從第二項(xiàng)開始,其分子是前一項(xiàng)的分子與分母之和,其分母是前一項(xiàng)

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論