Planet's Moon attrated by sun I'm currently writing a code to generate solar system and $N$ number of planets / moons.
I use real data to test (earth / sun / moon data).
I succeeded in placing the earth and make it orbit around the sun using the correct mass and velocity. But when I place the moon around the earth and launch the simulation, the moon is a kind of ignoring Earth.
At start $(x,y)$:
Sun : 0,0
Earth : 1.4959826e8
Moon : 1.4959826e8-384400
using $F = (G \times a.mass \times b.mass) / (dist \times dist)$ 
At start $F$:
Sun & Earth: 3.5855635298968626E22
Earth & moon : 1.9817101152925866E20
Moon & Sun: 4.379973928784021E20  
Since I placed them on $y=0$, moon has an $f_y$ of $0$ and $f_x$ of -2.39826381349143456E17 (because she's placed between sun and earth
At start, the moon has a velocity of 0.001022 km/sec
After velocity update ($v = v + dt \times F / mass$)
$v =$ 0.28200845732138924
$v_x =$ -0.28200660544886147
$v_y =$ 0.001022  
So regarding the result, it make sense that the moon is attracted more by the sun than the earth (since vx is negative), but why? Where in my formulas I make a mistake ? I tested also to start the simulation with the velocity of moon = 29.783 + 0.001022 , (earth velocity) but then the moon just turn around the sun like the earth
(I surely forgot to put some info, don't hesitate to tell me to add things , I'm not really used to ask physics questions) 
(Here's a video if you want an idea of what happen)
 A: The velocity of the Moon is obviously about the same as the Earth because it orbits at about the same distance. If you set the Moon's initial velocity to it's orbital velocity relative to the Earth (NB 1.022km/sec not 1.022m/sec as you state) then it will just fall towards the Sun, as indeed you've found.
You say:

I tested also to start the simulation with the velocity of moon = 29.783 + 0.001022 , (earth velocity) but then the moon just turn around the sun like the earth

Well you would expect the Moon to orbit the Sun just like the Earth. The orbit of the Moon looks extremely similar to the Earth because the distance from the Earth to the Moon is just 0.25% of the distance from the Earth to the Sun. The movement around the Earth is a small perturbation of the orbit round the Sun.
A: I just understand why this was happening.
I use the BarnesHut method and it doesn't work here , I don't really know why , the only explanation I see is because the tree ignore some force update sometimes , I tried to look out but didn't managed to get why.
Anyway when I use brute force on it , it's work like a charme (here's a video) 
