import java.util.*;
public class javademo{
public static void main(String args[]){
int a,b,m;
Scanner s=new Scanner(System.in);
System.out.println("请输入一个数:");
a=s.nextInt();
System.out.println("请输入另一个数:");
b=s.nextInt();
deff de=new deff();
m=de.deff(a,b);
int n=a*b/m;
System.out.println("最大公约数为:"+m);
System.out.println("最大公倍数为:"+n);
}
}
class deff{
public int deff(int x,int y){
int t,k;
if(x<y){t=x;x=y;y=t;}
while(y!=0){
if(x==y){return x;}
else{k=x%y;x=y;y=k;}
}
return x;
}
}
import java.util.*;
public class javademo{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
System.out.println("请输入数a:");
int a=s.nextInt();
System.out.println("请输入相加项数:");
int n=s.nextInt();
int sum=0,b=0;
for(int i=0;i<n;i++){
b=b+a;
sum=sum+b;
a=10*a;
}
System.out.println(sum);
}
} |
|