Skip to main content

Posts

Showing posts from April, 2016

NEAREST PRIME

Program 10: Nearest Prime Of A Number For Example User inputted 100 then 101 is nearest prime user inputs 102 then 103 and 101 are nearest primes. user inputs 97 then 97 itself is a prime. import java.io.*; class np //nearstprime   {        int posprime,negprime;         public void checkip(int n)              { int i,c=0;                for(i=2;i<n;i++)                 {                   if(n%i==0)                     {                        c++;                      }                   }             if(c==0)   ...