View Code of Problem 80

#include <stdio.h>
int main()
{
    int n, m=3, i, s = 0;
    while(scanf("%d", &n)!=EOF)
    {
    	if(n==0)break;
    	s = 0;
  	  	for (i = 2; i <= n; i++)
   		 {
        	s = (s + m) % i;
   		 }
    	printf ("%d\n", s+1);
    }
  
}

Double click to view unformatted code.


Back to problem 80