#include
#include
int gongyuemax(int x, int y)
{
for(int i=(x
{
if(x%i == 0&&y%i == 0)
{
return(i);
break;
}
}
}
int gongbeimin(int x, int y)
{
for(int i = (x>y)? x:y; i!=0;i++)
{
if(i%x == 0&&i%y == 0)
{
return(i);
break;
}
}
}
int jiechengji(int x)
{
if(x==1||x==0)
{
return(1);
}
else
return(x*jiechengji(x-1));
}
int leijiahe(int x)
{
int sum = 0;
for(int i = 1; i<=x; i++)
{
sum = sum + i;
}
return(sum);
}
void panduanshushu(int x)
{
int i;
int y = sqrt(x);
for(i = 2; i<=y;i++)
{
if(x%i==0)
{
printf("it isn't a shushu\n");
break;
}
}
if(i>y)//这里用i和y比较得出素数,且i不能定义在for语句里面,因为i和y比较式在for语句外进行的
printf("it is a shushu\n");
}
Ncifang(int x,int y)
{
long sum = 1;
for(int i=1; i<=y;i++)
{
sum *=x;
}
return(sum);
}
void main()
{
int x1, y1, n, a, b, c, d, e, N;
printf("请输入需要求解的数:\n");
scanf("%d%d",&x1, &y1);
a = gongyuemax(x1, y1);//求最大公约数
b = gongbeimin(x1, y1);//求最小公倍数
printf("输出最大公约数和最大公倍数:\n");
printf("%d\n%d\n", a, b);
printf("请输入任意数n:");
scanf("%d",&n);
c = jiechengji(n); //求任意数n的阶乘
d = leijiahe(n); //求任意数n的累加和
panduanshushu(n); //判断是不是素数?
printf("输出n的阶乘和累加和:\n");
printf("%d\n%d\n", c, d);
printf("输入任意数n及其它的次方N:");
scanf("%d%d",&n,&N);
e = Ncifang(n, N); //求任意数n的N次方
printf("%d\n",e);
}
Private Sub Form_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim n As Integer
For n = 100 To 999
a = n \ 100
b = (n - a * 100) \ 10
c = n Mod 10
If a ^ 3 + b ^ 3 + c ^ 3 = n Then
Print n
End If
Next
End Sub