Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

# 123456789

20 replies to this topic
aronincool
• Guests
• Last active:
• Joined: --
guys,
how do i make a macro which makes the keyboard press 123456789 automatically in a loop till i stop it....
thx

• Members
• 1704 posts
• Last active: Nov 19 2015 11:58 AM
• Joined: 10 Mar 2011
here ya go

```
x := 1

Loop
{
Send {%x%}

if (x == 10)
x := 1
else
x := x + 1
}

return
```

• Guests
• Last active:
• Joined: --
Could I get a script to calculate the 1 billion digits of π (pi)?

• Members
• 323 posts
• Last active: Apr 08 2012 01:26 PM
• Joined: 23 Mar 2012
Would not getting the exact value of pi be more desirable?

`MsgBox pi = π`

Thank you! <---In case I forget to say it.

• Members
• 323 posts
• Last active: Apr 08 2012 01:26 PM
• Joined: 23 Mar 2012

Would not getting the exact value of pi be more desirable?

```Loop
{
MsgBox, 4,, pi = π.  Close enough?
IfMsgBox, Yes
Break
}
ExitApp```

Here's an algorithm for you...I just don't know how to code it. It'd be interesting to see if another could.

pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)

So loop that enough times and the square root of that series should nudge up pretty close to π. A billion digits? Can AHK handle that?

Here's another one:

pi = 3 + (1/(6 + 3^2/(6 + 5^2/ (6 + 7^2/(6 + 9^2/(6 + 11^2/(....
Thank you! <---In case I forget to say it.

• Members
• 475 posts
• Last active: Oct 21 2014 11:08 AM
• Joined: 31 Jul 2008
<!-- m -->http://www.optimnem.co.uk/pi.php<!-- m -->
Any code that I post will be for AHK Basic.
I'm not always right, but I still try to help.

• Guests
• Last active:
• Joined: --

pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)

```pi := 6/1
Loop, % 1000000000 - 1
pi += 6/(A_Index^2)
pi := sqrt(pi)```

...?

• Members
• 755 posts
• Last active: Sep 08 2016 06:26 PM
• Joined: 25 Aug 2011

pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)

```pi := 6/1
Loop, % 1000000000 - 1
pi += 6/(A_Index^2)
pi := sqrt(pi)```

...?

Not right... that formula is wrong. This one works though 3+(1/(6+3**2/(6+5**2/(6+7**2..., but Autohotkey is not capable of making it for too long. My guess was to try and make it in parts, but I'm not in the mood to think about that right now.
Let us not be lazy. Someday it might just kill us.

• Members
• 323 posts
• Last active: Apr 08 2012 01:26 PM
• Joined: 23 Mar 2012

pi = sqrt(6/1 + 6/2^2 + 6/3^2 + ...)

```pi := 6/1
Loop, % 1000000000 - 1
pi += 6/(A_Index^2)
pi := sqrt(pi)```

...?

Not right... that formula is wrong. This one works though 3+(1/(6+3**2/(6+5**2/(6+7**2..., but Autohotkey is not capable of making it for too long. My guess was to try and make it in parts, but I'm not in the mood to think about that right now.

The first formula is right. It's Euler's solution to the Basel problem, solved for pi. Euler proved that the summation as n goes from 1 to infinity of 1/n^2 is pi^2/6. Multiplying through by 6 would give us that pi^2 = the summation as n goes from 1 to infinity of 6/n^2. Taking the square root of both sides would produce pi = the square root of (6/1 +6/2^2 + 6/3^2...). It's the code that "Guest" wrote that's wrong.
Thank you! <---In case I forget to say it.

• Guests
• Last active:
• Joined: --
How does that code differ from your posted algo (1st one)?

• Members
• 323 posts
• Last active: Apr 08 2012 01:26 PM
• Joined: 23 Mar 2012

How does that code differ from your posted algo (1st one)?

That code is calculating a bunch of nested square roots rather than the square root of the sum.

Edit: The code below works pretty good. It produces 3.141018. I tried 100000 loops and it locked up on me.
```Loop, 10000
{
pi += 1/(A_Index**2)
}
pi := sqrt(6*pi)
MsgBox, 4,, pi = %pi%...Close enough?
IfMsgBox, Yes
return```

Thank you! <---In case I forget to say it.

• Members
• 323 posts
• Last active: Apr 08 2012 01:26 PM
• Joined: 23 Mar 2012
Is there a limit on how many loops AHK will run?
Thank you! <---In case I forget to say it.

• Members
• 755 posts
• Last active: Sep 08 2016 06:26 PM
• Joined: 25 Aug 2011
Well... Autohotkey just finished making 100000000 (yup 8 0's) and it return only 16 decimal places... Took over half a hour for that and returned this 3.1415926449823899. Anyone willing to try a greater amount of loops?

PS: I've used setformat for it to show 50 decimal places.
Let us not be lazy. Someday it might just kill us.

• Guests
• Last active:
• Joined: --

That code is calculating a bunch of nested square roots rather than the square root of the sum.

No it's not....
```pi := 6/1 ; Start off as 6
Loop, % 1000000000 - 1 ; Loop 1 less than a billion
pi += 6/(A_Index^2) ; Add up 6/(A_Index^2)... the loop stops here
pi := sqrt(pi) ; Calc the final square root... square root is only calc'd once```

• Guests
• Last active:
• Joined: --
BTW, ^ is a bitwise-exclusive-or (^) in AHK, just in case that's trashing the formula.