Pairs with common factors: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (grammar fixes) |
(Add Factor) |
||
Line 48: | Line 48: | ||
<br> |
<br> |
||
=={{header|Factor}}== |
|||
{{works with|Factor|0.99 2022-04-03}} |
|||
<lang factor>USING: formatting grouping io kernel math math.functions |
|||
math.primes.factors prettyprint ranges sequences |
|||
tools.memory.private ; |
|||
: totient-sum ( n -- sum ) |
|||
[1..b] [ totient ] map-sum ; |
|||
: a ( n -- a(n) ) |
|||
dup [ 1 - * 2 / ] keep totient-sum - ; |
|||
"Number of pairs with common factors - first 100 terms:" print |
|||
100 [1..b] [ a commas ] map 10 group simple-table. nl |
|||
7 <iota> [ dup 10^ a commas "Term #1e%d: %s\n" printf ] each</lang> |
|||
{{out}} |
|||
<pre> |
|||
Number of pairs with common factors - first 100 terms: |
|||
0 0 0 1 1 4 4 7 9 14 |
|||
14 21 21 28 34 41 41 52 52 63 |
|||
71 82 82 97 101 114 122 137 137 158 |
|||
158 173 185 202 212 235 235 254 268 291 |
|||
291 320 320 343 363 386 386 417 423 452 |
|||
470 497 497 532 546 577 597 626 626 669 |
|||
669 700 726 757 773 818 818 853 877 922 |
|||
922 969 969 1,006 1,040 1,079 1,095 1,148 1,148 1,195 |
|||
1,221 1,262 1,262 1,321 1,341 1,384 1,414 1,461 1,461 1,526 |
|||
1,544 1,591 1,623 1,670 1,692 1,755 1,755 1,810 1,848 1,907 |
|||
Term #1e0: 0 |
|||
Term #1e1: 14 |
|||
Term #1e2: 1,907 |
|||
Term #1e3: 195,309 |
|||
Term #1e4: 19,597,515 |
|||
Term #1e5: 1,960,299,247 |
|||
Term #1e6: 196,035,947,609 |
|||
</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |