❤️ Author: 老九
☕️ 个人博客:老九的CSDN博客
🙏 个人名言:不可控之事 乐观面对
😍 系列专栏:vue
public class test1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
f(n);
}
private static void f(int n) {
if(n<0) return;
if(n == 0) return;
long r = n;
for(int i = n-1;i>=1;i--){
r *= i;
}
System.out.println(n+"阶乘是"+r);
}
}
public class test1 {
public static void main(String[] args) {
for(int i = 1;i<=100;i++){
int tail = i%10;
if(tail == 3||tail == 5||tail == 7){
continue;
}
System.out.println(i);
}
}
}
//在 2到 1+n开方范围(数学理论),找能把n整除的值(这个值也称作因子)
//如果找到可以把n整除的第三个数,那n就不是质数,反之,n为质数
public class test1 {
public static void main(String[] args) {
System.out.println("请输入要判断的自然数");
int n = new Scanner(System.in).nextInt();
getPrimeNumber(n);
}
private static void getPrimeNumber(int n) {
if(n<2){
System.out.println(n+"不是质数");
}
if(n == 2){
System.out.println(n+"是质数");
}else{
double max = 1+Math.sqrt(n);
for(int i = 2;i<max;i++){
if(n%i == 0){
System.out.println(n+"不是质数");
return;
}
}
System.out.println(n+"是质数");
}
}
}
public class test1 {
public static void main(String[] args) {
System.out.println("输入整数n,求n内质数的数量");
int n = new Scanner(System.in).nextInt();
count(n);
}
private static void count(int n) {
if(n<2){
System.out.println("没有质数");
return;
}
if(n == 2){
System.out.println("有一个质数");
return;
}
int count = 1;
int j;
for(int i = 3;i<=n;i++){
double max = 1+ Math.sqrt(i);
for( j = 2;j<max;j++){
if(i%j == 0) {
break;
}
}
if(j>=max)
count++;
}
System.out.println(n+"内质数的数量:"+count);
}
}
public class test2 {
public static void main(String[] args) {
System.out.println("请输入您要打印星星的行数");
int n = new Scanner(System.in).nextInt();
for(int i = 1;i<=n;i++){
for(int j = 0;j<n-i;j++){
System.out.print(" ");
}
for(int k = 1;k<=2*i-1;k++){
System.out.print("*");
}
System.out.println();
}
}
}
public class test2 {
public static void main(String[] args) {
System.out.println("请输入要求和的自然数");
int n = new Scanner(System.in).nextInt();
int sum = 0;
while(n!= 0){
sum = sum + (n%10);
n/=10;
}
System.out.println(sum);
}
}
public class test2 {
public static void main(String[] args) {
for(int i = 1;i<=1000;i++){
int sum = 0;
for(int j = 1;j<=i/2;j++){
if(i%j == 0){
sum +=j;
}
}
if(sum == i){
System.out.println(i);
}
}
}
}
public class test2 {
public static void main(String[] args) {
System.out.println("请输入您要测试的数");
int n = new Scanner(System.in).nextInt();
if(n<1){
System.out.println("输入的数据有误");
}
if(n == 1){
System.out.println(0+"\t");
}
if(n == 2){
System.out.println(0+"\t"+1+"\t");
}
if(n == 3){
System.out.println(0+"\t"+1+"\t"+1);
}
if(n>3){
System.out.println(0+"\n"+1+"\n"+1);
int f1 = 1;
int f2 =1;
int next = 0;
for(int i = 4;i<=n;i++){
next = f1 + f2;
f1 = f2;
f2 = next;
System.out.println(next);
}
}
}
}
public class test2 {
public static void main(String[] args) {
for(int i = 100;i<1000;i++){
if(isAim(i)){
System.out.println(i);
}
}
}
private static boolean isAim(int i) {
int x = i/100;
int y = i/10%10;
int z = i%10;
if(i == x*x*x+y*y*y+z*z*z){
return true;
}
return false;
}
}
————————————————————————
♥♥♥码字不易,大家的支持就是我坚持下去的动力♥♥♥
版权声明:本文为CSDN博主「亚太地区百大最帅面孔第101名」的原创文章