Hello, I have calculated using this table:- [FONT="]Input Register[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]Output Register[/FONT] [FONT="]|0>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]1[/FONT] [FONT="]|1>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]7[/FONT] [FONT="]|2>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]4[/FONT] [FONT="]|3>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]13[/FONT] [FONT="]|4>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]1[/FONT] [FONT="]|5>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]7[/FONT] [FONT="]|6>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]4[/FONT] [FONT="]|7>[/FONT] [FONT="]7 Mod 15[/FONT] [FONT="]13[/FONT] Code: #include<stdio.h> #include<math.h> mod_func(long int n1,long int n2) { long int i,w,m; for(i=0;i<15;i++) { w=pow(n1,i); m=w%n2; printf("m=%ld\n",m); } } main() { long int n1,n2,limit; clrscr(); printf("enter n1:"); scanf("%ld",&n1); printf("enter n2:"); scanf("%ld",&n2); mod_func(n1,n2); getch(); } Now I want to calculate the PERIOD.In the above output we find the pattern "1,7,4,13" to repeat itself.Hence it is the PERIOD.Can you please write the code for how to match this pattern...it should be generic so that it will respont for any given numbers.....can u please help me out......

The table cant be seen properly. so I am typing it as follows.. the TABLE IS :- (7 power a) Mod 15 m (7 power 0) Mod 15 - 1 (7 power 1) Mod 15 - 7 (7 power 2) Mod 15 - 4 (7 power 3) Mod 15 - 13 (7 power 4) Mod 15 - 1 (7 power 5) Mod 15 - 7 (7 power 6) Mod 15 - 4 (7 power 7) Mod 15 - 13 Now,I hope u can understand what I mean.

Not going to write it for you. How would you do it on paper? Take one new number at a time, for example: can you see a period in 1? What about in 1,7? What about in 1,7,4? What about in 1,7,4,13? What about in 1,7,4,13,1? If yes, how do you know? Can you think of a way to write a test that a computer can work out? Is there any storage you might need? Do you have to find a complete period twice to determine that there is a repeating pattern? For example 1,7,4,13,1,9,3,6 has a period > 4, but does the maths behind the calculation indicate that 1 must always be followed by 7, which must always be followed by 4 etc? What is (7^n) / (7^(n-1)) ?

And what should the program do if someone cruelly tosses in a digits-of-pi generator and asks it to find the period?