| Bytes | Lang | Time | Link |
|---|---|---|---|
| 031 | Redirection | 250819T160135Z | m90 |
| 022 | APLNARS | 250817T084445Z | Rosario |
| 2322 | x86 32bit machine code | 250817T194018Z | m90 |
| 011 | 05AB1E | 250818T071800Z | Kevin Cr |
| 010 | Nekomata + e | 250818T020809Z | alephalp |
| 049 | Retina 0.8.2 | 250817T064023Z | Neil |
| 010 | Jelly | 250816T184349Z | Jonathan |
| 233 | Bespoke | 250816T111742Z | Josiah W |
| 018 | Uiua | 250816T231926Z | nyxbird |
| 021 | Charcoal | 250816T090208Z | Neil |
| 033 | Python | 250816T081116Z | Albert.L |
| 032 | JavaScript ES6 | 250816T125540Z | Arnauld |
| 107 | Python 3.8 prerelease | 250816T051442Z | Ted |
| 015 | Vyxal | 250816T051800Z | lyxal |
Re:direction, 31 bytes
+++>
v
++++>
v v
+++++
>>> >^
Outputs by exit code, 0 if the process continues forever and 1 (by queue underflow) if it ends.
The input number n initialises the queue with n >s and one v.
The first loop divides by 3, going down at a position determined by the remainder. The next loop similarly divides by 4.
Remainders of (0, 0) lead back to the top-left corner to repeat. Remainders of (0, 2) lead into the third loop to divide by 5, and any remainder other than 2 follows the >s into the bottom-right ^, which points to itself to end execution.
Any other remainders result in entering one of the loops without a v in the queue, which eventually ends with a queue underflow.
APL(NARS), 22 chars
6=30∨{0≠12∣⍵:⍵⋄∇⍵÷12}⎕
Input in stdin the number, output in stdout 1 for the number is in the sequence, else 0. It seems that are in sequence all numbers k: exist i,j
k=i*12^j and j>=0 and gcd(i,30)=6
It is take one day for understand what Jonathan Allan said in comment...thank you
test:
6=30∨{0≠12∣⍵:⍵⋄∇⍵÷12}⎕
⎕:
582
1
6=30∨{0≠12∣⍵:⍵⋄∇⍵÷12}⎕
⎕:
583
0
x86 32-bit machine code, 23 22 bytes
99 8D 4A 0C 60 F7 F1 01 D2 74 FA 39 CA 61 75 04 B1 05 F7 F1 92 C3
Following the regparm(1) calling convention, this function takes n as a signed 32-bit integer in EAX and returns a number in EAX, which is nonzero if the process continues forever and zero if it terminates.
In assembly:
f: cdq # Set EDX to 0 by sign-extending EAX.
lea ecx, [edx + 12] # Set ECX to EDX+12 = 12.
pusha # Push the values of the general-purpose registers.
r: div ecx # Divide EDX:EAX by ECX, which is 12.
# Put the quotient in EAX and the remainder in EDX.
add edx, edx # Add EDX to itself, doubling it.
jz r # If it's 0, jump back to repeat.
cmp edx, ecx # Compare EDX (the doubled remainder) and ECX (12).
popa # Restore the pushed register values: EAX=n, EDX=0.
jnz e # Jump unless the comparison was equal (remainder 6).
mov cl, 5 # Set ECX's low byte to 5, making ECX 5.
div ecx # Divide EDX:EAX by ECX, which is 5.
# Put the quotient in EAX and the remainder in EDX.
e: xchg edx, eax # Exchange EAX and EDX.
ret # Return.
05AB1E, 11 bytes
·12в0Ü12βT¿
Port of @alephalpha's Nekomata answer, so make sure to upvote that answer as well!
Outputs an 05AB1E truthy/falsey result, which is 1 for truthy, and any other integer (in this case 2, 5 or 10) for falsey.
Try it online or verify all truthy values below 1000 or verify the outputs of all values below 1000.
A more direct implementation of the challenge would be 15 bytes instead:
ΔÑDg4@s¨3.£O*}Ā
Try it online or verify all truthy values below 1000.
And using the prime factorization method explained at the bottom of the challenge, with @Neil's comment in addition to that, would be 13 bytes:
Ó¬É*0ª3£`_·*‹
Try it online or verify all truthy values below 1000.
Explanation:
· # Double the (implicit) input-integer
12в # Then convert it to a base-12 list
0Ü # Trim all trailing 0s
12β # Convert it back from a base-12 list to a base-10 integer
T¿ # Get the Greatest Common Divisor with 10
# (after which it is output implicitly as result)
Δ # Loop until the value no longer changes, using the (implicit) input:
Ñ # Get all divisors of this value
D # Duplicate the list of divisors
g # Pop this copy and push its length
4@ # Check that this length is >=4
s # Swap to get the list of divisors again
¨ # Remove the last item (the value itself)
3.£ # Then get the last three values of this list of proper divisors
O # Sum them together
* # Multiply it to the earlier length>=4 check
}Ā # After the changes loop: check that the result is NOT 0
# (after which the result is output implicitly)
Ó # Get the prime exponents of the (implicit) input-integer
¬ # Push its first exponent (of prime 2) (without popping the list)
É # Check whether it is odd
* # Multiply that odd-check to each value in the list
0ª # Append a 0 in case there are just 1 or 2 items in the list
3£ # Pop and keep just the first three values
` # Pop and push them to the stack
_ # Check that the top value (exponent of prime 5) is 0
· # Double that check
* # Multiply it to the exponent of prime 3
‹ # Check that the second value is larger than the first
# (after which the result is output implicitly)
Nekomata + -e, 10 bytes
Äʷ{12¦}¢Gƶ
Attempt This Online! Or see the truthy results up to 100.
Based on this comment on OEIS:
Numbers
kof the form6*i*12^j, wheregcd(i, 10) = 1andj >= 0.
Äʷ{12¦}¢Gƶ
Ä Multiply by 2
ʷ{12¦} Repeatedly divide by 12 until no longer divisible
¢G GCD with 10
ƶ Check if the result is 1
Retina 0.8.2, 49 bytes
.+
$*
+`^(.+)\1{11}$
$1
A`^(.{5})\1*$
^(.{6})\1*$
Try it online! Link includes test cases. Explanation: Another port of @JosiahWinslow's answer.
.+
$*
Convert to unary.
+`^(.+)\1{11}$
$1
Repeatedly divide multiples of 12 by 12.
A`^(.{5})\1*$
Result must not be a multiple of 5.
^(.{6})\1*$
Result must be a multiple of 6.
Jelly, 10 bytes
ÆḌṫ-2SƲƬṢƑ
A monadic Link that accepts a positive integer and yields 1 for forever or 0 for terminating.
Try it online! Or see the truthy results up to 50,000.
How?
Instead, consider repeatedly summing the up to three largest proper divisors...
If a number, \$n\$, is divisible by either: $$3 \times 4 = 12$$ $$2 \times 3 \times 5 = 30$$ then the sum of the three largest proper divisors will be greater than \$n\$, with, respectively:
$$f(n) = n(\frac{1}{2} + \frac{1}{3} + \frac{1}{4})$$ $$f(n) = n(\frac{1}{2} + \frac{1}{3} + \frac{1}{5})$$
While, since:
$$\frac{1}{2} + \frac{1}{3} + \frac{1}{6} = 1$$ $$\frac{1}{2} + \frac{1}{3} + \frac{1}{7} = \frac{41}{42} < 1$$
...the only way not to decrease when summing the up to three largest proper divisors would be for the number to be divisible by \$6\$ while not satisfying either of the previous cases, whereupon it is a fixed point since now:
$$f(n) = n(\frac{1}{2} + \frac{1}{3} + \frac{1}{6}) = n$$
Thus, the chain of values starting with a forever \$n\$ will either itself be a fixed point or will ascend to a fixed point, while a terminating \$n\$ will, at some point, descend.
ÆḌṫ-2SƲƬṢƑ - Link: positive integer, N
Ƭ - collect, starting with k=N, while distinct under:
Ʋ - last four links as a monad - f(k):
ÆḌ - proper divisors
ṫ - tail from 1-index...
-2 - ...minus two
-> up to 3 largest proper divisors of k
S - sum
Ƒ - is invariant under?:
Ṣ - sort
Original, more direct, method at \$13\$ bytes:
b12t0ḅ12g30⁼6
b12t0ḅ12g30⁼6 - Link: N
b12t0ḅ12 - convert to base 12, trim zeros, convert from base 12
-> N divided by 12 until no longer possible
g30 - greatest common divisor of {that} and 30
-> product of divisors from 2, 3, and 5
⁼6 - does {that} equal six?
Bespoke, 233 bytes
heres a curious problem in math
add of N3of greatest proper divisor;if it does loop,which formulas decide it?simple
just repeat dividing twelve,defining N=division remainder
answer:N divisor six,and of N no divisors constitute five^X
Outputs a truthy value if the given process continues forever, and 0 if it doesn't.
Continually divides by 12 until there's a remainder, and then checks whether the result mod 5 is nonzero and the result mod 6 is zero.
EDIT: Changed N divides six to N divisor six, because the proper way to use the word "divides" here would be "six divides N". This does not change the functionality of the code.
Uiua, 18 bytes
±⍥(/+⍣↙₋₃0⊚=0◿⊸⇡)∞
Try it!
this assumes that all sequences reach fixed points (which is apparently true!)
⍥( # repeat:
◿⊸⇡ # modulo by range
⊚=0 # where equals zero
⍣ # try:
↙₋₃ # take last three
0 # fail with zero
/+ # sum
)∞ # until fixed point
± # sign?
Charcoal, 38 21 bytes
NθW¬﹪θ¹²≧÷¹²θ∧﹪θ⁵¬﹪θ⁶
Try it online! Link is to verbose version of code. Explanation: Now a port of @JosiahWinslow's answer.
Nθ
Input n.
W¬﹪θ¹²≧÷¹²θ
Divide n by 12 as many times as possible.
∧﹪θ⁵¬﹪θ⁶
Check that n is a multiple of 6 but not of 5.
Python, 33 bytes
-1 thanks to @Arnauld
f=lambda a:a%5>a%6*6<a%12+f(a/12)
Previous Python, 34 bytes
f=lambda a:a%5>a%6*6<a%12+f(a//12)
Previous Python, 36 bytes
f=lambda a:a%5>a%6<(0<a%12)|f(a//12)
Previous Python, 39 bytes
f=lambda a:a%5>0==a%6<(a%12or f(a//12))
Uses the criteria given at the end of OP.
Python 3.8 (pre-release), 107 bytes
f=lambda n,s=[]:1if len(d:=[x for x in range(1,n)if not n%x])<3else 0if(k:=sum(d[-3:]))in s else f(k,s+[k])
Brute force python approach which runs recursively and checks if it has seen a given number before.
Vyxal, 15 bytes
KṪ3_ȯ₅3=¨i∑0)↔t
Outputs 0 if falsey, a positive integer if truthy.
Try a test suite mapping the output to explicitly 0 for falsey and 1 for truthy.
Explained
KṪ3_ȯ₅3=¨i∑0)↔t
)↔ # Repeat on the input, until the result doesn't change:
KṪ3_ȯ # Get the last 3 (3_ == -3) factors of the input
₅3=¨i # If (¨i) the length is 3:
∑ # Use the sum of the factors as the next input
0 # Otherwise, set the next input to 0
t # Get the last item of that.
💎
Created with the help of Luminespire.