这是我的计划。我需要一个帮助才能完成以下问题 [英] here is my program. i need a help to complete this for the following question

查看:81
本文介绍了这是我的计划。我需要一个帮助才能完成以下问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数字素数是素数,其数字之和也是素数。

例如素数23是数字素数因为2 + 3 = 5而5是素数。 17不是数字素数因为1 + 7 = 8,而8不是素数。编写一个程序,找出小于1000000的特定范围内的数字素数。并打印范围之间的第M个数字素数。











A digit prime is a prime number whose sum of digits is also prime.
For example the prime number 23 is a digit prime because 2+3=5 and 5 is a prime number. 17 is not a digit prime because 1+7 = 8, and 8 is not a prime number. Write a program to find out the number of digit primes within a certain range less than 1000000.and also print the Mth digit prime number between the range.





#include<stdio.h>

int main()
{
   int n, i = 3, count, c;

   printf("Enter the number of prime numbers required\n");
   scanf("%d",&n);

   if ( n >= 1 )
   {
      printf("First %d prime numbers are :\n",n);
      printf("2\n");
   }

   for ( count = 2 ; count <= n ;  )
   {
      for ( c = 2 ; c <= i - 1 ; c++ )
      {
         if ( i%c == 0 )
            break;
      }
      if ( c == i )
      {
         printf("%d\n",i);
         count++;
      }
      i++;
   }

   return 0;
}

推荐答案

请参阅此链接中的答案 IsPrime 功能 - C - 确定数字是否为素数 [ ^ ]

我相信你可以从那里拿走它。
See the answer in this link for the IsPrime function - C - determine if a number is prime[^]
I'm sure you can take it from there.


这篇关于这是我的计划。我需要一个帮助才能完成以下问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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