# Introduction

I stumbled across this (useless) pattern the other day while I was watching TV. I named it "the 9 pattern" because the first number to use it was 9. The gist of it is, you enter a number (let's say x), and then you get back:

• x
• x + (x / 3) [let's call this y]
• two-thirds of y [let's call this z]
• z + 1

So, if I put inside this pattern the number 9 as x, this is what would come out:

• 9 (9)
• 12 (9 + 9 / 3) [9 over 3 is 3, and 9 + 3 is 12]
• 8 (12 times two-thirds) [a third of 12 is 4, and 4 * 2 is 8]
• 9 (8 + 1 is 9)

# Challenge

Write me a function (in any programming language) that takes in a number, and outputs an integer array using the pattern.
Somewhat like this psuedo-code:

function ninePattern(int myInt) returns IntegerArray {
int iterationA = myInt + (myInt / 3);
int iterationB = iterationA * (2 / 3);
int iterationC = iterationB + 1;
IntegerArray x = [myInt, iterationA, iterationB, iterationC];
return x;
}


# Clarifications

Discussions have been arousing in comments regarding the specifications of the question. This section is meant to clarify some of those.

## "better to count in bytes than characters"

I picked characters because (for me, at least) it would be easier to judge. Of course, I can't change that now. (lots of answers are already posted)

## "rounding"

Rounding follows this rhyme:

If it's 5 or more, raise the score
If it's 4 or less, let it rest

Simply, put, if it is something like 4.7 or 3.85, round them to 5 and 4 respectively.

### Examples

Input => Result
9 => [9, 12, 8, 9]
8 => [8, 11, 7, 8]
6 => [6, 8, 5, 6]
23 => [23, 31, 21, 22]
159 => [159, 212, 141, 142]


If, however, the numbers are something like 2.3 or 10.435446, round them to 2 and 10 respectively.

## "language support"

You are free to not use functions and/or arrays IF AND ONLY IF the language of your choice does not support them. If it does (even if it will increase your characters count), you must use them.

• Must the output be an array, or are the numbers by themselves enough (like the Pyth answer)? May 24 '16 at 0:46
• You are free to restrict to just full programs, or just functions, but there is discussion on meta of the defaults, which gives some useful background in case it affects your decision for future challenges. By default challenges accept both, to allow more languages to compete. May 24 '16 at 1:38
• There are defaults for input and output too. Again, you don't have to follow them, this is just to let you know. May 24 '16 at 1:46
• -1 for the arbitrary array and function requirements, which prevents languages without an array/list type or functions from competing.
– user45941
May 24 '16 at 4:15
• Also, you should score the contestants in bytes, not in characters. We have a Sandbox, where you can get feedback on your post before it goes live. May 24 '16 at 5:21

# MarioLANG, 659621591582556543516458418401352308 369 bytes

rounding is quite expensive :/

Try it online

;>>[![( [( [( [( [( [<(([!)))!+(((-<>( >((+
:"==#================"===#== #=====""[ "==
)(  -[!)>>[![)  [)[<(!>)[<)) >))) [!!-[!((
(  )"#="==#======="=#==="=<="=====##==#==<
+  +>) )-+<>+)[!)+! +))![-[)>[ [([-[![<<:
+  )-+ )(=""===#==#  ==#===)"=======#=====
+  >!>)!>  !(- < !:+:))<  ))!((++)))<
)  "#"=#===#===" ======" ===#======="
!
=#========================


Well this was more fun than expected, this is probably not optimal but I guess i'm getting there.

Explanation time:

(for the 352 bytes version)

first we get the argument and print it :

;
:


simple enough

we then move to the bulk of the program : the division input / 3

;>>[![              [( [( [<result
:"==#======================"======
)   -[!)>>[![        [<((((!
)   )"#="==#=========="====#
+(  +>) )  +>(+)[!)+))!
+(  )-+ )  -"====#====#
+   >!>)!  >! -  <
"#"=#  "#===="
!
=#


which is a slightly modified conversion of the brainfuck division

[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]


which take for input

n 0 d 0 0


and give you back

0 n d-n%d n%d n/d


once we got the division we use it to get the sum of n and n/d and print it

;>>[![              [( [( [<    !+(((-<
:"==#======================"===)#====="
)   -[!)>>[![        [<((((!    >))) [!(((
)   )"#="==#=========="====#   ="=====#==:
+(  +>) )  +>(+)[!)+))!
+(  )-+ )  -"====#====#
+   >!>)!  >! -  <
"#"=#  "#===="
!
=#


we then need to do another division : ( 2 * ( n + n / d ) ) / 3

so we get ( 2 * ( n + n / d )

;>>[![              [( [( [<    !+(((-<
:"==#======================"===)#====="
)   -[!)>>[![        [<((((!    >))) [!(((
)   )"#="==#=========="====#   ="=====#==:
+(  +>) )  +>(+)[!)+))! 2*2n/d>[   -[![  <
+(  )-+ )  -"====#====# ======"======#====
+   >!>)!  >! -  <            !((++))<
"#"=#  "#===="            #======"
!
=#


and put it with 3 back into the division

;>>[![              [( [( [<    !+(((-<
:"==#======================"===)#====="
)   -[!)>>[![        [<((((!    >))) [!(((
)   )"#="==#=========="====#   ="=====#==:
+(  +>) )  +>(+)[!)+))!      )>[   -[![  <
+(  )-+ )  -"====#====#      )"======#====
+   >!>)!  >! -  <       +++))!((++))<
"#"=#  "#====" ===========#======"
!
=#=================


at that point everything explose, mario is stuck in an infinite loop doing division on bigger and bigger number, forever.

and to fix that we need a way to diferenciate between the first and the second division, it end up that, oh joy, we do have a way

;>>[![              [( [( [<([!)!+(((-<
:"==#======================"==#)#====="
)   -[!)>>[![        [<((((!))< >))) [!(((
)   )"#="==#=========="====#)="="=====#==:
+(  +>) )  +>(+)[!)+))!!:+:)))>[   -[![  <
+(  )-+ )  -"====#====#======)"======#====
+   >!>)!  >! -  <       +++))!((++))<
"#"=#  "#====" ===========#======"
!
=#=================


basically we look if the x in

x 0 n d-n%d n%d n/d


is 0, if it is it mean we are on the first division

else we are on the second division, and we just print the result of the division, add 1 then print it again

and voilà easy as pie.

• Welcome to PPCG! May 24 '16 at 12:17
• Doesn't round to the specs provided by the question (of course, I did update it after you posted your answer, but you should at least update your answer to fit the new specs) May 27 '16 at 23:39
• Done. while we are talking about test case you should add 10 to have a number that you round down on the fist operation. May 28 '16 at 23:56

# Emotinomicon 99 bytes, 33 characters

😷😭,😲🆙🆙😼🆙😨😎⏬😎🆙😍➗➕🆙😨😎⏬😎😉✖😍➗🆙😨😎⏬😎😅➕😨


Explanation:

😷                                 clear output
😭                                begin quote string
,
😲                              end quote string
🆙                             duplicate top of stack
🆙                            duplicate top of stack
😼                           take numeric input
🆙                          duplicate top of stack
😨                         pop N and output as a number
😎                        reverse stack
⏬                       pops and outputs top of stack as character
😎                      reverse stack
🆙                     duplicate top of stack
😍                    push 3 to the stack
➗                   divide top two elements on stack
➕                  add top two elements on stack
🆙                 duplicate top of stack
😨                pop N and output as a number
😎               reverse stack
⏬              pops and outputs top of stack as character
😎             reverse stack
😉            push 2 to the stack
✖           multiply top two elements on stack
😍          push 3 to the stack
➗         divide top two elements on stack
🆙        duplicate top of stack
😨       pop N and output as a number
😎      reverse stack
⏬     pops and outputs top of stack as character
😎    reverse stack
😅   push 1 to the stack
➕  add top two elements on stack
😨 pop N and output as a number

• Yay for unconventional languages! :P May 26 '16 at 19:19

# MATL, 14 bytes

Xot4*3/tE3/tQv


Try it Online

Pretty simple, v concatenates the stack into an array. Xo converts to an integer data-type, and all operations thereafter are integer operations.

• The spec is to return an array, not the final result only. May 24 '16 at 0:27
• Also lol at those flagging for deletion in <2 minutes :D May 24 '16 at 0:36
• @David D: I don't think I can retract deletion votes May 24 '16 at 0:39
• @David upvoted your answer as my condolences :) May 24 '16 at 0:48
• I'm pretty sure this isn't a function either, correct me if I'm wrong. May 24 '16 at 1:03

# Cheddar, 27 bytes

b=8/9*$0 [$0,$0+$0/3,b,b+1]


$0 is variable with input. Cheddar just isn't a golfy language ¯\_(ツ)_/¯ , also this is non-competing because Cheddar's input functionality was made after this challenge. Ungolfed: IterationB := 8 / 9 *$0  // 8/9ths of the Input

# PHP, 67 bytes

function f($x){return [$x,$y=round($x*4/3),$z=round($y*2/3),\$z+1];}
`