← RoseCode

ROSECODE 234

Programming exercise - Fractions madness

Philippe_57721 · Programming ·

Consider the sequence of fractions:
F={2395,5723,1739,13017,1114,3511,1913,119,352,137,71}

We define the following algorithm (n is an integer):
func(n){
  i = 0;
  Start:
    j = 0;
    while (F[j]*n not integer) {
        j++;
    }
    i++;
    n = n*F[j]
    if (n has only factors 2 and 3){
        print(i);
    }
    goto Start;
}
The first values func(6) yield are:
- 10, 24, 46, ...

Find the 100th value

You are given the 20-th element: 185500

[My timing: < 100 ms]