You need to sign in to do that
Don't have an account?

prime numbers: Error: Compile Error: line 15:8 no viable alternative at character '%' at line 15
public class prime
{
public void m1(integer a)
{
integer n,i,s,c;
for(n=1;n<=a;n++)
{
c=0;
for(i=1;i<=n;i++)
{
s=0;
s=n%i;
if(s==0)
{
c++;
}
}
if(c==2)
{
System.debug('---------------->'+n);
}
}
}
}
At the line number 15
Instead of
s=n%i;
if(s==0)
Please use this . .
s = Math.Mod(n,1);
if (s == 0)
Please mark this as solution if it solves the issue ..
Thanks
SFDC_Evolve
Sorry ... It wass i not 1
s = Math.Mod(n,i);