改成VB以内的全部整数

改成VB以内的全部整数#include<stdio.h>main(){int a,i,b,n;printf("there are following friendly-numbers pair smaller than 3000:尀n");for(a=1;a<3000;a++){for(b=0,i=1;i<=a/2;i++)if(! (a%i))b+=i;for(n=0,i=1;i<=b/2; i++)if(!(b%i))n+=i;if(n==a&&a<b)printf(" %4d..%4d ",a,b);}}
2026年09月25日 04:15
有1个网友回答
网友(1):

Sub main()
Dim a%, i%, b%, n%
Debug.Print "there are following friendly-numbers pair smaller than 3000:"
For a = 1 To 2999
b = 0
For i = 1 To a / 2
If a Mod i = 0 Then b = b + i
Next
n = 0
For i = 1 To b / 2
If b Mod i = 0 Then n = n + i
Next
If (n = a And a < b) Then Debug.Print a; " .. "; b
Next
End Sub