Prompt user for an integer

Read the integer inton

IFnis less than 2

Setprimeto 0 ( 0 means false, i.e.nis not prime )

ELSE

Setprimeto 1 ( 1 means true, i.e. assumenis prime )

FOR values ofifrom 2 ton- 1 (irepresents all numbers smaller than n )

IFndivided byigives no remainder

Setprimeto 0 ( 0 means false, i.e.nis not prime )

BREAK ( jump out from the loop )

END IF

END FOR

END IF

IFprime= 1

Print message for prime number

ELSE

Print message for not prime number

END IF

I follow this algorithm but it's not working ...

Anyone help please?Code:#include <stdio.h> int main () { int n, i, prime; printf("Enter a number : "); scanf("%d", &n); if (n<2) { prime = 0; } else { prime = 1; for (i=2;i<n;n--) { if (n%i==0) { prime = 0; break; } } } if (prime==1) { printf("Prime number\n", n); } else { printf("Not a prime number\n", n); } return 0; }