Fractran: Difference between revisions

Content added Content deleted
(→‎Revised Code: Output of zero powers is replaced by spaces.)
Line 1,080: Line 1,080:
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
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
Start with N = 2, step limit 28
Start with N = 2, step limit 28
Require primes only up to Prime(10) = 29
Require 10 primes only, up to Prime(10) = 29


N as powers of prime factors
N as powers of prime factors
Step F#: 2 3 5 7 11 13 17 19 23 29
Step F#: 2 3 5 7 11 13 17 19 23 29
0 : 1 0 0 0 0 0 0 0 0 0
0 : 1
1 13: 0 1 1 0 0 0 0 0 0 0
1 13: 1 1
2 14: 0 1 2 0 1 0 0 0 0 0
2 14: 1 2 1
3 5: 0 0 2 0 0 0 0 0 0 1
3 5: 2 1
4 6: 0 0 2 1 1 0 0 0 0 0
4 6: 2 1 1
5 11: 0 0 2 1 0 1 0 0 0 0
5 11: 2 1 1
6 1: 0 0 2 0 0 0 1 0 0 0
6 1: 2 1
7 2: 1 1 1 0 0 1 0 0 0 0
7 2: 1 1 1 1
8 10: 1 1 1 0 1 0 0 0 0 0
8 10: 1 1 1 1
9 5: 1 0 1 0 0 0 0 0 0 1
9 5: 1 1 1
10 6: 1 0 1 1 1 0 0 0 0 0
10 6: 1 1 1 1
11 11: 1 0 1 1 0 1 0 0 0 0
11 11: 1 1 1 1
12 1: 1 0 1 0 0 0 1 0 0 0
12 1: 1 1 1
13 2: 2 1 0 0 0 1 0 0 0 0
13 2: 2 1 1
14 10: 2 1 0 0 1 0 0 0 0 0
14 10: 2 1 1
15 5: 2 0 0 0 0 0 0 0 0 1
15 5: 2 1
16 6: 2 0 0 1 1 0 0 0 0 0
16 6: 2 1 1
17 11: 2 0 0 1 0 1 0 0 0 0
17 11: 2 1 1
18 1: 2 0 0 0 0 0 1 0 0 0
18 1: 2 1
19 9: 2 0 0 0 0 0 0 0 0 0
19 9: 2
20 13: 1 1 1 0 0 0 0 0 0 0
20 13: 1 1 1
21 13: 0 2 2 0 0 0 0 0 0 0
21 13: 2 2
22 14: 0 2 3 0 1 0 0 0 0 0
22 14: 2 3 1
23 5: 0 1 3 0 0 0 0 0 0 1
23 5: 1 3 1
24 6: 0 1 3 1 1 0 0 0 0 0
24 6: 1 3 1 1
25 5: 0 0 3 1 0 0 0 0 0 1
25 5: 3 1 1
26 6: 0 0 3 2 1 0 0 0 0 0
26 6: 3 2 1
27 11: 0 0 3 2 0 1 0 0 0 0
27 11: 3 2 1
28 1: 0 0 3 1 0 0 1 0 0 0
28 1: 3 1 1
</pre>
</pre>
This time, restricting output to only occasions when N is a power of two requires no peculiar bit-counting function. Just change the interpretation loop to <lang Fortran> DO I = 1,M !Here we go!
This time, restricting output to only occasions when N is a power of two requires no peculiar bit-counting function. Just change the interpretation loop to <lang Fortran> DO I = 1,MS !Here we go!
IT = FRACTRAN(L) !Do it!
IT = FRACTRAN(LF) !Do it!
IF (ALL(NPPOW(2:LP).EQ.0)) WRITE (6,103) I,IT,NPPOW(1:LP) !Show it!
IF (ALL(NPPOW(2:LP).EQ.0)) CALL SHOWN(I,IT) !Show it!
END DO !The next step. </lang>
103 FORMAT (I9,I4,":",<LP>I6) !As a sequence of powers of primes.
END DO !The next step. </lang>


Output:
Output:
Line 1,126: Line 1,125:
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
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
Start with N = 2, step limit 6666666
Start with N = 2, step limit 6666666
Require primes only up to Prime(10) = 29
Require 10 primes only, up to Prime(10) = 29


N as powers of prime factors
N as powers of prime factors
Step F#: 2 3 5 7 11 13 17 19 23 29
Step F#: 2 3 5 7 11 13 17 19 23 29
0 : 1 0 0 0 0 0 0 0 0 0
0 : 1
19 9: 2 0 0 0 0 0 0 0 0 0
19 9: 2
69 9: 3 0 0 0 0 0 0 0 0 0
69 9: 3
280 9: 5 0 0 0 0 0 0 0 0 0
280 9: 5
707 9: 7 0 0 0 0 0 0 0 0 0
707 9: 7
2363 9: 11 0 0 0 0 0 0 0 0 0
2363 9: 11
3876 9: 13 0 0 0 0 0 0 0 0 0
3876 9: 13
8068 9: 17 0 0 0 0 0 0 0 0 0
8068 9: 17
11319 9: 19 0 0 0 0 0 0 0 0 0
11319 9: 19
19201 9: 23 0 0 0 0 0 0 0 0 0
19201 9: 23
36866 9: 29 0 0 0 0 0 0 0 0 0
36866 9: 29
45551 9: 31 0 0 0 0 0 0 0 0 0
45551 9: 31
75224 9: 37 0 0 0 0 0 0 0 0 0
75224 9: 37
101112 9: 41 0 0 0 0 0 0 0 0 0
101112 9: 41
117831 9: 43 0 0 0 0 0 0 0 0 0
117831 9: 43
152025 9: 47 0 0 0 0 0 0 0 0 0
152025 9: 47
215384 9: 53 0 0 0 0 0 0 0 0 0
215384 9: 53
293375 9: 59 0 0 0 0 0 0 0 0 0
293375 9: 59
327020 9: 61 0 0 0 0 0 0 0 0 0
327020 9: 61
428553 9: 67 0 0 0 0 0 0 0 0 0
428553 9: 67
507519 9: 71 0 0 0 0 0 0 0 0 0
507519 9: 71
555694 9: 73 0 0 0 0 0 0 0 0 0
555694 9: 73
700063 9: 79 0 0 0 0 0 0 0 0 0
700063 9: 79
808331 9: 83 0 0 0 0 0 0 0 0 0
808331 9: 83
989526 9: 89 0 0 0 0 0 0 0 0 0
989526 9: 89
1273490 9: 97 0 0 0 0 0 0 0 0 0
1273490 9: 97
1434366 9: 101 0 0 0 0 0 0 0 0 0
1434366 9: 101
1530213 9: 103 0 0 0 0 0 0 0 0 0
1530213 9: 103
1710923 9: 107 0 0 0 0 0 0 0 0 0
1710923 9: 107
1818254 9: 109 0 0 0 0 0 0 0 0 0
1818254 9: 109
2019962 9: 113 0 0 0 0 0 0 0 0 0
2019962 9: 113
2833089 9: 127 0 0 0 0 0 0 0 0 0
2833089 9: 127
3104685 9: 131 0 0 0 0 0 0 0 0 0
3104685 9: 131
3546320 9: 137 0 0 0 0 0 0 0 0 0
3546320 9: 137
3720785 9: 139 0 0 0 0 0 0 0 0 0
3720785 9: 139
4549718 9: 149 0 0 0 0 0 0 0 0 0
4549718 9: 149
4755581 9: 151 0 0 0 0 0 0 0 0 0
4755581 9: 151
5329874 9: 157 0 0 0 0 0 0 0 0 0
5329874 9: 157
5958403 9: 163 0 0 0 0 0 0 0 0 0
5958403 9: 163
6400897 9: 167 0 0 0 0 0 0 0 0 0
6400897 9: 167</pre>
</pre>
Execution took about two seconds.
Execution took about two seconds.