从500开始,求被3,5,7除余数均为2的前50个数

来源:百度知道 编辑:UC知道 时间:2024/05/17 22:06:12

Private Sub Command1_Click()
Dim a, i As Integer
Dim s As String

For a = 500 To 10000
If a Mod 3 = 2 And a Mod 5 = 2 And a Mod 5 = 2 Then
s = s & a & " "
i = i + 1
If i >= 50 Then Exit For
End If
Next
Label1.Caption = s
End Sub

512 527 542 557 572 587 602 617 632 647 662 677 692 707 722 737 752 767 782 797 812 827 842 857 872 887 902 917 932 947 962 977 992 1007 1022 1037 1052 1067 1082 1097 1112 1127 1142 1157 1172 1187 1202 1217 1232 1247

int i=0
a=500
while(ture)
{ if(i<50)
{
if(i % 3 == 2 && i % 5 == 2 && i % 7 == 2)
printf(i)
a++
}else break
}

void main()
{
int n=500/(3*5*7);
int count=50;
int i;
if (n*3*5*7+2>500)
{
prinf(3*5*7*n+2);
count--;
}

for(i=1;i<=count;i++){
printf((n+i)*3*5*7+2);