7.Wechall-------------Prime Factory by ch0wch0w(得分2个)

0x01:问题

题目题目链接地址
Prime Factoryhttp://www.wechall.net/challenge/training/prime_factory/index.php

0x02:WP

提示提示解题步骤
Your task is simple:Find the first two primes above 1 million, whose separate digit sums are also prime.As example take 23, which is a prime whose digit sum, 5, is also prime.The solution is the concatination of the two numbers,Example: If the first number is 1,234,567 and the second is 8,765,432,your solution is 12345678765432运行一个java代码,算出质数。注意,下面的代码,要对应的包
package First;   //注意这条,代码对应着你这个类的包。
public class First_100w {

    public static void main(String[] args){

        int flag=0;
        StringBuilder ss=new StringBuilder("");
        for(int i=1000001;;i=i+2){
            if(isPrime(i)&&isPrimeToo(i)){
                System.out.println(i);
                flag++;
                ss.append(i);
            }
            if(flag==2){
                System.out.println(ss);
                break;
            }
        }
    }

    public static boolean isPrime(int a){
        int mid=(int)(Math.sqrt(a));
        for(int i=2;i<=mid;i++){
            if(a%i==0){
                return false;
            }
        }
        return true;
    }

    public static boolean isPrimeToo(int a){
        int sum=0;
        while(a!=0){
            sum+=a%10;
            a=a/10;
        }
        return isPrime(sum);

    }
}
//注意:该代码为借鉴的!!!

在这里插入图片描述

0x03:passwd/flag

passwd:10000331000037
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qwsn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值