发布网友 发布时间:2022-05-10 12:09
共2个回答
热心网友 时间:2023-10-09 07:59
Function isprime(n) As Integer
isprime = 0
For i = 3 To Sqr(n + 1) Step 2
If n Mod i = 0 Then
Exit Function
End If
Next i
isprime = 1
End Function
Private Sub Command1_Click()
n = 0
Label1.Caption = ""
For i = 3 To 100 Step 2
If isprime(i) = 1 Then
Print i;
n = n + 1
If n Mod 10 = 0 Then Print
Label1.Caption = Label1.Caption & i & " "
End If
Next i
End Sub
=================
//求完数
#include<stdio.h>
int sum1(int n)
{int s=1,i;
if(n==1)return 0;
for(i=2;i<=n/2;i++)
if(n%i==0)s+=i;
return s;
}
int main()
{ int i,j,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
if(sum1(i)==i)
{printf("%d=1",i);
for(j=2;j<=i/2;j++)
if(i%j==0)printf("+%d",j);
printf("\n");
}
return 0;
}
热心网友 时间:2023-10-09 07:59
#include <stdio.h>