Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 12 = 2 * 2 * 3 -> 3 * 3 * 3 = 27
- 1 -> 1
- 2 -> 3
- 3 -> 3
- 4 -> 9
- 5 -> 5
- 6 -> 9
- 7 -> 7
- 8 -> 27
- 9 -> 9
- 10 -> 15
- 11 -> 11
- 12 -> 27
- 13 -> 13
- 14 -> 21
- 15 -> 15
- 16 -> 81
- 17 -> 17
- 18 -> 27
- 19 -> 19
- 20 -> 45
- 21 -> 21
- 22 -> 33
- 23 -> 23
- 24 -> 81
- 25 -> 25
- 26 -> 39
- 27 -> 27
- 28 -> 63
- 29 -> 29
- 3/2
- 3/2
- / Replace a factor of
- 2 2
- 3 with 3
- {implicit: repeat until no more replacements are possible}
- Ò1~P
- Ò Compute the prime factorization of the input.
- 1~ Perform bitwise OR with 1, making the only even prime (2) odd (3).
- P Take the product of the result.
- until odd$(*3).(`div`2)
- odd`until`x->div(x*3)2
- f=x=>x%2?x:f(x*1.5)
- #//.x_?EvenQ:>3x/2&
- {{({}[()]<([({})]()<({}{})>)>)}{}([{}]()){{}((({})){}{})<>}<>}<>({}({}){}())
- Yf1Z|p
- Yf % Prime factors
- [2 2 2 3]
- 1Z| % Bitwise OR with 1
- [3 3 3 3]
- p % Product
- 81
- Yfto~+p
- ÒDÈ+P
- Ò # push list of prime factors of input
- D # duplicate
- È # check each factor for evenness (1 if true, else 0)
- + # add list of factors and list of comparison results
- P # product
- 2/S 3
- o@i
- 2 Push 2 (irrelevant).
- / Reflect to SE. Switch to Ordinal.
- i Read all input as a string.
- The IP bounces up and down, hits the bottom right corner and turns around,
- bounces down again.
- i Try to read more input, but we're at EOF so this pushes an empty string.
- / Reflect to W. Switch to Cardinal.
- 2 Push 2.
- The IP wraps around to the last column.
- 3 Push 3.
- S Implicitly discard the empty string and convert the input string to the integer
- value it contains. Then replace the divisor 2 with the divisor 3 in the input.
- This works by multiplying the value by 3/2 as long as it's divisible by 2.
- / Reflect to NW. Switch to Ordinal.
- Immediately bounce off the top boundary. Move SW.
- o Implicitly convert the result to a string and print it.
- Bounce off the bottom left corner. Move NE.
- / Reflect to S. Switch to Cardinal.
- @ Terminate the program.
- Æf3»P
- Æf3»P Main Link, argument is z
- Æf Prime factors
- 3» Takes maximum of 3 and the value for each value in the array
- P Takes the product of the whole thing
- *^1.5/PQ2
- .+
- $*
- +`^(1+)1$
- $&$1
- 1
- ~×₂×₃↰|
- ~×₂×₃↰| original program
- ?~×₂×₃↰.|?. with implicit input (?) and output (.) added
- ?~×₂ input "un-multiplied" by 2
- ×₃ multiplied by 3
- ↰ recursion
- . is the output
- | or (in case the above fails, meaning that the input
- cannot be "un-multiplied" by 2)
- ?. the input is the output
- [:*/q:+2=q:
- (+2&=)&.q:
- (2&={,&3)"+&.q:
- (2&={,&3)"+&.q:
- &. "under"; applies the verb on the right, then the left,
- then the inverse of the right
- q: prime factors
- ( )"+ apply inside on each factor
- ,&3 pair with three: [factor, 3]
- 2&= equality with two: factor == 2
- { list selection: [factor, 3][factor == 2]
- gives us 3 for 2 and factor for anything else
- &.q: under prime factor
- *F+1.|R1P
- *F+1.|R1P
- P prime factorization
- .|R1 bitwise OR each element with 1
- *F+1 product
- k ®w3Ã×
- k ® w3Ã ×
- Uk mZ{Zw3} r*1
- U # (input)
- k m # for every prime factor
- Z{Zw3} # replace it by the maximum of itself and 3
- r*1 # output the product
- k mw3 ×
- k mw3 ×
- k // Factorize the input.
- mw3 // Map each item X by taking max(X, 3).
- × // Take the product of the resulting array.
- // Implicit: output result of last expression
- rimf2Zer:*
- ri e# Read integer: | 28
- mf e# Prime factors: | [2 2 7]
- 2 e# Push 2: | [2 2 7] 2
- Z e# Push 3: | [2 2 7] 2 3
- er e# Replace: | [3 3 7]
- :* e# Product: | 63
- x=gmp::factorize(scan());x[x==2]=3;prod(x)
- P1.|B
- &>:2%!#v_.@
- ^*3/2 <
- & - take in input and add it to the stack
- > - move right
- : - duplicate the top of the stack
- 2 - add two to the stack
- % - pop 2 and the input off the stack and put input%2 on the stack
- ! - logical not the top of the stack
- # - jump over the next command
- _ - horizontal if, if the top of the stack is 0 (i.e. input%2 was non zero) go
- right, else go left
- If Zero:
- . - output the top of the stack
- @ - end code
- If Not Zero:
- v - move down
- < - move left
- 2 - add 2 the top of the stack
- / - pop top two, add var/2 to the stack
- 3 - add 3 to stack
- * - pop top two, add var*3 to the stack
- ^ - move up
- > - move right (and start to loop)
- w⌠i1|ⁿ⌡Mπ
- w⌠i1|ⁿ⌡Mπ
- w factor into [prime, exponent] pairs
- ⌠i1|ⁿ⌡M for each pair:
- i flatten
- 1| prime | 1 (bitwise OR)
- ⁿ raise to exponent
- π product
- f(n)=if(n%2,n,f(3*n/2))
- n->n*1.5^valuation(n,2)
Add Comment
Please, Sign In to add comment