Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- #include<stdbool.h>
- bool array[50];
- bool arr[50];
- bool Perplexing_Primes(int n)
- {
- if(n<=1)
- return false;
- if(n==2)
- return true;
- if(n>2 && n%2==0)
- return false;
- int div = sqrt(n);
- for(int i=3;i<=div;i+=2)
- if(n%i==0)
- return false;
- return true;
- }
- void Multiplicated_Value(int n)
- {
- while(n%2 == 0){
- arr[2] = true;
- n/=2;
- }
- for(int i= 3; i<=sqrt(n);i+=2){
- while(n%i==0){
- arr[i] = true;
- n/=i;
- }
- }
- if(n>2)
- arr[n] = true;
- }
- int main()
- {
- int n = (55 % 5) + 31;
- for(int i=1;i<n+4;i++){
- array[i] = Perplexing_Primes(i);
- }
- for(int i=1;i<=n;i++){
- if(array[i] == true && array[i+2] == true){
- array[i] = true;
- array[i+2] = true;
- i+=2;
- }
- else
- array[i] = false;
- }
- Multiplicated_Value(n);
- bool ok = false;
- for(int i=1;i<=n;i++){
- if(array[i] == true && arr[i] == true){
- ok = true;
- printf("%d is a twin prime!\n", i);
- }
- }
- if(!ok){
- printf("No twin prime there\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment