-9
\$\begingroup\$

Your challenge is to write a program or function to output this sequence of numbers.

Output requirements:

  • Must contain numbers specified above
  • Must be in order as specified
  • Numbers must be delimited by whitespace

Shortest code in bytes wins.

\$\endgroup\$
  • \$\begingroup\$ Ah, feck, I've figured out 2 formulas for this but it's too fiddly to write them up, test them & golf them down on my phone. \$\endgroup\$ – Shaggy Jun 12 '17 at 19:23
  • 1
    \$\begingroup\$ OEIS Sequence \$\endgroup\$ – Okx Jun 12 '17 at 20:06
  • \$\begingroup\$ A033312 \$\endgroup\$ – Shaggy Jun 12 '17 at 20:18
  • 9
    \$\begingroup\$ Guessing how you've generated a sequence is a poor fit for code golf. Once one person has solved the "puzzle", everyone can copy the idea. \$\endgroup\$ – xnor Jun 12 '17 at 20:22
  • \$\begingroup\$ @xnor Alright, I'll add modified version \$\endgroup\$ – user1761786 Jun 12 '17 at 20:23
5
\$\begingroup\$

Python, 76 bytes

from math import*
s=2**32-5
for i in range(6499):print((s-factorial(i+1))%s)

A033312.

Python, 84 bytes

from math import*
k=s=2**32-6
for i in range(6499):s-=i*factorial(i);s%=k+1;print(s)

A001563.

\$\endgroup\$
  • \$\begingroup\$ Do you really need k=? As far as I can tell, k=s=... and s never changes so why not remove the k= and make %k into %s? \$\endgroup\$ – caird coinheringaahing Jun 12 '17 at 22:38
  • \$\begingroup\$ @cairdcoinheringaahing thanks \$\endgroup\$ – Uriel Jun 12 '17 at 22:57
  • \$\begingroup\$ You can save 1 cheap byte by not importing *; Try it online! \$\endgroup\$ – musicman523 Jun 24 '17 at 0:11
2
\$\begingroup\$

Python 3, 148 bytes

a=[1]
n=6499
N=2**32-5
exec("a+=[a[-1]*len(a)%N];"*n)
a=[i*a[i]for i in range(n)]
for i in range(1,n):a[i]=(a[i]+a[i-1])%N
print([N-i-1 for i in a])

Try it online!

Surely this can be golfed.

\$\endgroup\$
  • \$\begingroup\$ Took you literally 10 minutes :) \$\endgroup\$ – Mr. Xcoder Jun 12 '17 at 19:26
  • \$\begingroup\$ @Mr.Xcoder I only checked the beginning and the end though. \$\endgroup\$ – Leaky Nun Jun 12 '17 at 19:26
1
\$\begingroup\$

Charcoal, 39 bytes

A⁻X²¦³²¦⁵σA¹φA¹κF⁶⁴⁹⁹«⁺﹪⁻σφσ¶A⁺κ¹κA×φκφ

Try it online!

Explanation

A         σ                                    Assign to s
  ⁻X²¦³²¦⁵                                     2 ** 32 - 5
            A¹φ                                Assign 1 to f (factorial)
                A¹κ                            Assign 1 to k
                    F⁶⁴⁹⁹«                     For i from 0 to 6498
                           ⁺﹪⁻σφσ¶             (s - f) % s + "\n" (implicitly printed)
                                   A⁺κ¹κ       k = k + 1
                                         A×φκφ Assign f * k to f
\$\endgroup\$
0
\$\begingroup\$

05AB1E, 19 bytes

žJ5-6499FDN>!-sDŠ%,

Try it online!

Only checked first and last numbers. If you run it TIO will probably take a while to print them all


Explanation

žJ5-                # (2 ** 32) - 5; call this x
    6499F           # for N in 0 .. 6498. Stack entering loop: [x]
         D          # duplicate. Stack: [x, x]
          N>        # N + 1. Stack: [x, x, N + 1]
            !       # factorial. Stack: [x, x, (N + 1)!]
             -      # subtract. Stack: [x, x - (N + 1)!]
              s     # swap. Stack: [x - (N + 1)!, x]
               D    # duplicate. Stack: [x - (N + 1)!, x, x]
                Š   # cycle last three items. Stack: [x, x - (N + 1)!, x]
                 %  # modulus. Stack [x, (x - (N + 1)!) % x)]
                  , # pop and print. Stack: [x]
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.