| |

VerySource

 Forgot password?
 Register
Search
View: 40|Reply: 11

Super prime

[Copy link]

1

Threads

3

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-2-13 21:30:01
| Show all posts |Read mode
Novice, to solve the super prime programming method, which prawn can help? Use C and VB.
Reply

Use magic Report

0

Threads

6

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

Post time: 2020-2-14 02:22:56
| Show all posts
It still needs to have a digit limit. It is relatively simple and straightforward to use an enumeration method.
Reply

Use magic Report

0

Threads

4

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

Post time: 2020-4-13 14:30:01
| Show all posts
What super prime numbers?
#include "stdio.h"
#include "conio.h"
#include "math.h"
main () {
 int i, j, k, s = 0, leap = 1;
 printf ("\n");
 for (i = 1; i <= 100; i ++)
 {k = sqrt (i + 1);
  for (j = 2; j <= k; j ++)
  if (i% j == 0)
  {leap = 0;
   break;
  }
  if (leap)
  {printf ("%-4d", i);
   s ++;
   printf ("\n");
  }
   leap = 1;
  }
  printf ("\nThe total is% d", s);
  getch ();
}
Reply

Use magic Report

0

Threads

6

Posts

5

Credits

Newbie

Rank: 1

Credits
5

 China

Post time: 2020-4-14 23:00:01
| Show all posts
Yeah, what are super prime numbers?
Reply

Use magic Report

0

Threads

4

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

Post time: 2020-4-15 09:45:02
| Show all posts
Can the lz question be clear. . ?
-_-
Reply

Use magic Report

0

Threads

10

Posts

11

Credits

Newbie

Rank: 1

Credits
11

 China

Post time: 2020-5-26 23:45:01
| Show all posts
#include <stdio.h>
#include <math.h>

int isPrime (int p);
int isSuperPrime (int p);

int main ()
{
int i;
for (i = 2; i <1000; i ++)
if (isSuperPrime (i))
printf ("% d\t", i);
return 0;
}


int isSuperPrime (int p)
{
if (isPrime (p)&&p> 10)
{
while (p> 10)
{
p / = 10;
if (! (isPrime (p)))
return 0;
}
return 1;
}
return 0;
}

int isPrime (int p)
{
int a, i;
if (p <2)
return 0;
else if (p == 2)
return 1;
a = (int) sqrt (p + 1);
for (i = 2; i <= a; i ++)
if (! (p% i))
return 0;
return 1;
}
Reply

Use magic Report

0

Threads

12

Posts

9

Credits

Newbie

Rank: 1

Credits
9

 China

Post time: 2020-5-29 16:00:01
| Show all posts
#include <stdio.h>
#include <math.h>

typedef unsigned long pr_t;

int pr_test (pr_t x)
{
pr_t i, sqx = (pr_t) sqrt (x);
for (i = 3; i <= sqx; i + = 2)
if (x% i == 0)
return 0;
return 1;
}

int slove (pr_t * p, pr_t * t, int n)
{
int r = 0, i, j;
for (i = 0; i <n; ++ i)
for (j = 1; j <= 9; j + = 2)
if (pr_test (p [i] * 10 + j))
t [r ++] = p [i] * 10 + j;
return r;
}

#define BUFF_SIZE (200)

int main ()
{
pr_t b1 [BUFF_SIZE] = {2, 3, 5, 7}, b2 [BUFF_SIZE];
pr_t * p = b1, * t = b2, * tt;
int n = 4, i;
while (n)
{
for (i = 0; i <n; ++ i)
printf ("% -10d", p [i]);
n = slove (p, t, n);
tt = p; p = t; t = tt;
}
printf ("\n\n");
return 0;
}
Reply

Use magic Report

0

Threads

68

Posts

45

Credits

Newbie

Rank: 1

Credits
45

 Invalid IP Address

Post time: 2020-6-24 11:30:01
| Show all posts
You can check the output number again, and remove those meanings 0, 1, 4, 6, 8, and 9.
Reply

Use magic Report

0

Threads

10

Posts

11

Credits

Newbie

Rank: 1

Credits
11

 China

Post time: 2020-6-24 21:30:02
| Show all posts
I wrote super prime numbers, lz did not take it seriously...
Reply

Use magic Report

0

Threads

2

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 China

Post time: 2020-6-28 20:30:01
| Show all posts
Transfer string to determine if it contains non-prime elements
itoa
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list