FRACTRAN

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

Implement a FRACTRAN interpreter. http://en.wikipedia.org/wiki/FRACTRAN. On the first line takes a space-separated list of fractions (numer denom numer denom ...). On the second line is the starting number (an integer). On the third line is the maximum number of steps to print. Print out the list of integers generated by the program. Make sure to print out the starting number too.

Options

exec is denied

now post-mortem time, all source codes will be revealed

Sample input:_

1 5 1 4 1 3 1 2
360
50

Sample output:

360
72
18
6
2
1

Sample input:_

91 66 11 13 1 33 85 11 57 119 17 19 11 17 1 3
3168
50

Sample output:

3168
4368
3696
5096
4312
33320
15960
14280
6840
6120
3960
5460
4620
6370
5390
41650
19950
17850
8550
7650
4950
6825
5775
175

Sample input:_

17 91 78 85 19 51 23 38 29 33 77 29 95 23 77 19 1 17 11 13 13 11 15 14 15 2 55 1
2
200

Sample output:

2
15
825
725
1925
2275
425
390
330
290
770
910
170
156
132
116
308
364
68
4
30
225
12375
10875
28875
25375
67375
79625
14875
13650
2550
2340
1980
1740
4620
4060
10780
12740
2380
2184
408
152
92
380
230
950
575
2375
9625
11375
2125
1950
1650
1450
3850
4550
850
780
660
580
1540
1820
340
312
264
232
616
728
136
8
60
450
3375
185625
163125
433125
380625
1010625
888125
2358125
2786875
520625
477750
89250
81900
15300
14040
11880
10440
27720
24360
64680
56840
150920
178360
33320
30576
5712
2128
1288
5320
3220
13300
8050
33250
20125
83125
336875
398125
74375
68250
12750
11700
9900
8700
23100
20300
53900
63700
11900
10920
2040
1872
1584
1392
3696
3248
8624
10192
1904
112
120
900
6750
50625
2784375
2446875
6496875
5709375
13321875
35371875
31084375
82534375
97540625
18221875
16721250
3123750
2866500
535500
491400
91800
84240
71280
62640
166320
146160
388080
341040
905520
795760
2112880
2497040
466480
428064
79968
29792
18032
74480
45080
186200
112700
465500
281750
1163750
704375
2909375
11790625
13934375
2603125
2388750
446250
409500
76500
70200
59400
52200
138600
121800
323400
284200
754600
891800
166600
152880
28560
26208
4896
1824
1104
4560

Ranking

Perl _

RankUserSizeTimeDateStatistics
1tails870.02082011/04/20 16:38:000B / 28B / 57B
2tails840.02202011/04/26 05:43:190B / 27B / 54B

Python _

RankUserSizeTimeDateStatistics
1hallvabo (last testcases missing 15159375)1670.07462011/04/08 20:20:590B / 94B / 55B

J _

RankUserSizeTimeDateStatistics
1I., S.800.15142011/06/09 20:27:020B / 32B / 45B

OCaml _

RankUserSizeTimeDateStatistics
1m.ukai2120.16622011/04/14 13:15:080B / 116B / 81B

gs2 _

RankUserSizeTimeDateStatistics
1whio330.25642017/07/28 23:22:3512B / 14B / 6B

Language Ranking_

RankLangUserSizeScore
1gs2whio3310000
2JI., S.804125
3Perltails843928
4Pythonhallvabo (last testcases missing 15159375)1671976
5OCamlm.ukai2121556

return to the top page