Jump to content

Undulating numbers: Difference between revisions

added Uiua solution
(Added Rust solution)
(added Uiua solution)
Line 1,593:
or expressed in base 7: 5252525252525252525.
</pre>
 
=={{header|Uiua}}==
{{works with|Uiua|0.10.0-dev.1}}
More of a script than a program, and only for base 10 as there's no built-in support for other radixes in Uiua yet.
<syntaxhighlight lang="Uiua">
# Generate all distinct two digit numbers as strings.
≡(°⋕)▽≡(≠0◿11).↘10⇡100
. &pf "Three digits: "
&p≡(⋕⊂⟜⊢)
. &pf "Four digits: "
&p≡(⋕⊂.)
. &pf "Three digit primes: "
≡(⋕⊂⟜⊢)
# Primes by sieve.
⇌◌⍢(▽≠0◿⊃⊢(.↘1)⟜(⊂⊢)|>0⧻)↘2⇡1000[]
&p▽:⟜(/+⍉⊞⌕):
 
# Collect all 3 and 4 digit numbers.
⊂⊃≡(⋕⊂⟜⊢)≡(⋕⊂.)
 
# Double-up last two digits of each and remove the ensuing duplicates.
F ← ◴⊂⟜≡(⋕⊂⟜(↙¯2)°⋕)
 
# Repeat until length is okay.
⍢(F|<600⧻)
. &pf "Six hundredth: "
&p⊡599
# Repeat until last is larger than target.
⍢(F|<ⁿ53 2⊡¯1)
&pf "Count less than 2^53: "
&p⧻.▽<ⁿ53 2.
&pf "Last one less than 2^53: "
&p⊡¯1⊏⍏.
</syntaxhighlight>
{{out}}
<pre>
Three digits: [101 121 131 141 151 161 171 181 191 202 212 232 242 252 262 272 282 292 303 313 323 343 353 363 373 383 393 404 414 424 434 454 464 474 484 494 505 515 525 535 545 565 575 585 595 606 616 626 636 646 656 676 686 696 707 717 727 737 747 757 767 787 797 808 818 828 838 848 858 868 878 898 909 919 929 939 949 959 969 979 989]
Four digits: [1010 1212 1313 1414 1515 1616 1717 1818 1919 2020 2121 2323 2424 2525 2626 2727 2828 2929 3030 3131 3232 3434 3535 3636 3737 3838 3939 4040 4141 4242 4343 4545 4646 4747 4848 4949 5050 5151 5252 5353 5454 5656 5757 5858 5959 6060 6161 6262 6363 6464 6565 6767 6868 6969 7070 7171 7272 7373 7474 7575 7676 7878 7979 8080 8181 8282 8383 8484 8585 8686 8787 8989 9090 9191 9292 9393 9494 9595 9696 9797 9898]
Three digit primes: [101 131 151 181 191 313 353 373 383 727 757 787 797 919 929]
Six hundredth: 4646464646
Count less than 2^53: 1125
Last one less than 2^53: 8989898989898989
</pre>
 
 
 
=={{header|Wren}}==
73

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.