Question

By using R programming Write a function that determines the amount of twin prime pairs there...

By using R programming

  1. Write a function that determines the amount of twin prime pairs there are

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program :

# Create a function to print squares of numbers in sequence.
twinprime <- function(n1=2,n2=5)
{
count=0;
cat("The twin Prime numbers are:\n")
for(n1 in 1:n2)
{
x<-n1+2
if(Checkprime(n1) && Checkprime(x)){

count=count+1
cat(n1," ",x)
cat("\n")
}
}
cat("The amount of Twin Prime number are:",count)
}
Checkprime <- function(n)
{
f=0
for(i in 1:n)
{
if(n%%i==0)
f<-f+1
}
if(f==2)
TRUE
else
FALSE
  
}

twinprime(1,100)


Screen shot of the out put:

Twin prime number between 1 and 100

If you have any doubt please comment

Add a comment
Know the answer?
Add Answer to:
By using R programming Write a function that determines the amount of twin prime pairs there...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT