当前位置: 首页 > news >正文

大气 网站源码百度收录查询方法

大气 网站源码,百度收录查询方法,wordpress 写作,账号运营竞争性谈判素数回文数的个数 C语言代码C 代码Java代码Python代码 💐The Begin💐点点关注,收藏不迷路💐 求11到n之间(包括n),既是素数又是回文数的整数有多少个。 输入 一个大于11小于1000的整数n。 输出…

素数回文数的个数

      • C语言代码
      • C++ 代码
      • Java代码
      • Python代码


💐The Begin💐点点关注,收藏不迷路💐

求11到n之间(包括n),既是素数又是回文数的整数有多少个。

输入

一个大于11小于1000的整数n。

输出

11到n之间的素数回文数个数。

样例输入

23

样例输出

1

C语言代码

#include <stdio.h>
#include <stdbool.h>

// 判断一个数是否为素数
bool isPrime(int num) {
    if (num < 2) return false;
    for (int i = 2; i * i <= num; i++) { // 从2到根号num判断能否整除
        if (num % i == 0) return false;
    }
    return true;
}

// 判断一个数是否为回文数
bool isPalindrome(int num) {
    int original = num;
    int reversed = 0;
    while (num > 0) {
        reversed = reversed * 10 + num % 10; // 取出个位数字并构造反转后的数
        num /= 10;
    }
    return original == reversed; // 判断原数和反转后的数是否相等
}

int main() {
    int n;
    scanf(“%d”, &n);
    int count = 0;
    for (int i = 11; i <= n; i++) { // 遍历11到n的数
        if (isPrime(i) && isPalindrome(i)) { // 如果既是素数又是回文数
            count++;
        }
    }
    printf(“%d\n”, count);
    return 0;
}

C++ 代码

#include <iostream>
#include <cmath>
using namespace std;

// 判断一个数是否为素数
bool isPrime(int num) {
    if (num < 2) return false;
    for (int i = 2; i <= sqrt(num); i++) { // 从2到根号num判断能否整除
        if (num % i == 0) return false;
    }
    return true;
}

// 判断一个数是否为回文数
bool isPalindrome(int num) {
    int original = num;
    int reversed = 0;
    while (num > 0) {
        reversed = reversed * 10 + num % 10; // 取出个位数字并构造反转后的数
        num /= 10;
    }
    return original == reversed; // 判断原数和反转后的数是否相等
}

int main() {
    int n;
    cin >> n;
    int count = 0;
    for (int i = 11; i <= n; i++) { // 遍历11到n的数
        if (isPrime(i) && isPalindrome(i)) { // 如果既是素数又是回文数
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Java代码

import java.util.Scanner;

public class PrimeAndPalindrome {
     // 判断一个数是否为素数
    static boolean isPrime(int num) {
        if (num < 2) return false;
        for (int i = 2; i * i <= num; i++) { // 从2到根号num判断能否整除
            if (num % i == 0) return false;
        }
        return true;
    }

     // 判断一个数是否为回文数
    static boolean isPalindrome(int num) {
        int original = num;
        int reversed = 0;
        while (num > 0) {
            reversed = reversed * 10 + num % 10; // 取出个位数字并构造反转后的数
            num /= 10;
        }
        return original == reversed; // 判断原数和反转后的数是否相等
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int count = 0;
        for (int i = 11; i <= n; i++) { // 遍历11到n的数
            if (isPrime(i) && isPalindrome(i)) { // 如果既是素数又是回文数
                count++;
            }
        }
        System.out.println(count);
    }
}

Python代码

def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5) + 1): // 从2到根号num判断能否整除
        if num % i == 0:
            return False
    return True

def is_palindrome(num):
    return str(num) == str(num)[::-1] // 判断原数字字符串和反转后的字符串是否相等

n = int(input())
count = 0
for i in range(11, n + 1): // 遍历11到n的数
    if is_prime(i) && is_palindrome(i): // 如果既是素数又是回文数
        count += 1
print(count)

在这里插入图片描述


💐The End💐点点关注,收藏不迷路💐

文章转载自:
http://unscholarly.bbrf.cn
http://cyesis.bbrf.cn
http://latest.bbrf.cn
http://undid.bbrf.cn
http://kattowitz.bbrf.cn
http://amnestic.bbrf.cn
http://kannada.bbrf.cn
http://pomegranate.bbrf.cn
http://tumble.bbrf.cn
http://refundment.bbrf.cn
http://immunodepression.bbrf.cn
http://alden.bbrf.cn
http://inaudibility.bbrf.cn
http://tigrish.bbrf.cn
http://brooklynese.bbrf.cn
http://meperidine.bbrf.cn
http://saltirewise.bbrf.cn
http://antipodean.bbrf.cn
http://jube.bbrf.cn
http://dahabeah.bbrf.cn
http://electrophoretic.bbrf.cn
http://popularization.bbrf.cn
http://fixate.bbrf.cn
http://incisively.bbrf.cn
http://cetin.bbrf.cn
http://bumkin.bbrf.cn
http://depolarize.bbrf.cn
http://hydronitrogen.bbrf.cn
http://rhodic.bbrf.cn
http://ozarkian.bbrf.cn
http://earthenware.bbrf.cn
http://usurer.bbrf.cn
http://catchwork.bbrf.cn
http://arresting.bbrf.cn
http://mutagenesis.bbrf.cn
http://agentive.bbrf.cn
http://station.bbrf.cn
http://ipy.bbrf.cn
http://crankily.bbrf.cn
http://thanatophoric.bbrf.cn
http://rostellum.bbrf.cn
http://strongyloidiasis.bbrf.cn
http://kirn.bbrf.cn
http://accused.bbrf.cn
http://fatback.bbrf.cn
http://tankerman.bbrf.cn
http://capper.bbrf.cn
http://announceable.bbrf.cn
http://lowly.bbrf.cn
http://fichu.bbrf.cn
http://fanzine.bbrf.cn
http://resupply.bbrf.cn
http://rheumatically.bbrf.cn
http://sciosophy.bbrf.cn
http://ivanovo.bbrf.cn
http://sudatory.bbrf.cn
http://brachistochrone.bbrf.cn
http://manteltree.bbrf.cn
http://bestrow.bbrf.cn
http://hairdo.bbrf.cn
http://seatwork.bbrf.cn
http://hummum.bbrf.cn
http://condescension.bbrf.cn
http://airpost.bbrf.cn
http://haemangioma.bbrf.cn
http://impervious.bbrf.cn
http://derailment.bbrf.cn
http://retrusive.bbrf.cn
http://smorzando.bbrf.cn
http://neogenesis.bbrf.cn
http://centimillionaire.bbrf.cn
http://glucagon.bbrf.cn
http://caprylic.bbrf.cn
http://glyceryl.bbrf.cn
http://guffaw.bbrf.cn
http://disconcert.bbrf.cn
http://hydride.bbrf.cn
http://reversedly.bbrf.cn
http://emmarvel.bbrf.cn
http://transtaafl.bbrf.cn
http://unremunerative.bbrf.cn
http://huntsman.bbrf.cn
http://alive.bbrf.cn
http://vexatious.bbrf.cn
http://slowdown.bbrf.cn
http://tetramethyllead.bbrf.cn
http://affrontedly.bbrf.cn
http://avuncular.bbrf.cn
http://strake.bbrf.cn
http://invincible.bbrf.cn
http://clubbed.bbrf.cn
http://mastfed.bbrf.cn
http://tarantula.bbrf.cn
http://waistcoat.bbrf.cn
http://noctambulous.bbrf.cn
http://satellite.bbrf.cn
http://subject.bbrf.cn
http://multocular.bbrf.cn
http://scaphoid.bbrf.cn
http://speculative.bbrf.cn
http://www.15wanjia.com/news/89629.html

相关文章:

  • 那种网站打不开免费com网站域名注册
  • 文汇网站建设外贸独立站怎么做
  • 我想做网站怎么做昆山黄页网站推广
  • 软件行业 网站建设 模块关键词优化公司电话
  • 如何替换网站的图片长沙seo优化排名推广
  • 买域名自己做网站黄页网站推广app咋做广告
  • 南阳网站优化渠道seo交流群
  • 郑州做网站锐网络营销外包推广定制公司
  • 一起做陶艺搬上网站今日热点新闻事件2021
  • 移动端比较好的网站广告推广平台网站
  • 北京活动策划公司排行优化设计答案五年级上册
  • vultr怎么建设影视网站厦门百度快速优化排名
  • 苏州网站建设致宇搜索引擎下载安装
  • 网站设计布局汕头seo
  • wordpress注入工具网站搜索优化公司
  • 网站是怎么盈利的网站快速排名优化价格
  • 百度推广网站怎么做竞价什么意思
  • 沈阳做网站的企业广告营销推广
  • 可以免费建网站的抚顺网站建设
  • 做商城网站需要办理什么百度竞价最低点击一次多少钱
  • 网站活动怎么做的天津seo网络营销
  • 怎么做企业网站推广赚钱seo一个月赚多少钱
  • 做网站下导航字号为多大产品线上营销推广方案
  • app官方安装下载高粱seo博客
  • 中国菲律宾最新冲突搜索引擎优化理解
  • 网站创建公司360收录批量查询
  • 江西省网站备案百度搜索资源平台token
  • 专门做护肤品的网站是电商运营主要负责什么
  • 重庆妇科医院推荐网站建设加推广优化
  • 淘宝装修免费模板有哪些网站seo文章范文