检查给定的号码是否是calypso [英] check given number is calypso or not

查看:76
本文介绍了检查给定的号码是否是calypso的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查传递的号码是否是calypso号码

int isCalypso(int n)

有谁能告诉我,任何逻辑或帮助对您来说对我来说都是足够的

How can i check that passed number is a calypso number or not

int isCalypso(int n)

Is there anyone who can tell me that any logic or help for that will be your kind enough for me

推荐答案

如果用"calypso数字"表示
If by "calypso number" you mean this then a naive implementation would be sometihng like:

bool isCalypso(int n)
{
    int pairCount=0;
    for (int i = 2; i <= n/2 && pairCount < 2; i++){
        if (isPrime(i) && isPrime(n-i) pairCount++;
    }
    return pairCount > 1;
}


这篇关于检查给定的号码是否是calypso的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆