I'm trying to get the square of prime numbers between 1:10 using for loop as below:
sq_pr_no=function()
{
sq_pr_no=c()
for (i in 1:10)
{
for (p in 2:i-1)
{
if (i%%p==0)
{
sq_pr_no=c(sq_pr_no,i^2)
}
}
}
}
and I'm getting error as follows
Error in if (i%%p == 0) { : missing value where TRUE/FALSE needed
Please help me to solve this
Thanks and Regards,
Arun kumar