To celebrate pi day, here's a spigot algorithm for computing it github.com/stuffpi/pispig…
πŸ‘︎ 38
πŸ’¬︎
πŸ‘€︎ u/pi_stuff
πŸ“…︎ Mar 14 2020
🚨︎ report
spigot algorithm in ada

so my code is

with ada.integer_text_io; use ada.integer_text_io;
with Ada.Text_IO; use Ada.Text_IO;

procedure Spigot is
n : constant Integer := 1000;
length : constant Integer := 10*n/3+1;
x,q,nines,predigit :Integer :=0;
a: array (0..length) of Integer;

begin
nines:=0;
predigit:=0;

for j in 0..length loop
   a(j):=2;
end loop;

for j in  1..n loop
   q:=0;
   for i in reverse 1..length loop
      x:=10*a(i) + q*i;
      a(i):= x mod (2*i-1);
      q:= x/(2*i-1);
   end loop;
  
   a(1):= q mod 10;
   q:=q/10;
  
   if q = 9 then
      nines:=nines+1;
   elsif q = 10 then
      put(predigit+1);
      for k in 0..nines loop
         put("0");
      end loop;
      predigit:=0;
      nines:=0;
   else
      put(predigit);
      predigit:=q;
      if nines/=0 then
         for k in 0..nines loop
            put("9");
         end loop;
         nines:=0;
      end if;      
   end if;   
end loop;
put(predigit);

end Spigot;

it should be outputting the digits of pi, 1 digit at a time but it's messing up and going 0 3 1 4 1 599 and then just messes up from there, and I can't figure out why

πŸ‘︎ 3
πŸ’¬︎
πŸ“…︎ Apr 05 2019
🚨︎ report
Spigot algorithms for Pi

Hello, /r/math.

I have recently stumbled upon the fact that individual hexadecimal digits of Pi can be generated using an algorithm.

This got me thinking: how on earth can some sequence be random if there's an algorithm for finding every member of it?! I thought Pi's digits were completely random...help me out on this I don't know what to do

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/arthur990807
πŸ“…︎ Aug 07 2014
🚨︎ report
Thinking about spigot-style shuffling algorithms, looking for ideas

Shuffling algorithms have been on my mind for a while. Specifically, I've been thinking about spigot-style algorithms: I want to calculate the next card in a shuffled deck, without calculating the rest of the deck.

For example, suppose I had a deck of 10 cards. I could rearrange them by setting new_card_position = old_card_position*3 mod 11:

This:     1,  2,  3,  4,  5,  6,  7,  8,  9, 10
Becomes:  3,  6,  9,  1,  4,  7, 10,  2,  5,  8

This works because 3 and 11 are coprime, which means 3 has an inverse mod 11 (i.e., multiply by 4), which means there's a one-to-one mapping -- and ta-da, you've defined a permutation! It's easy to do, and it kind of looks like a random shuffle (though you can see patterns if you look closely).

Here's a different permutation: new_card_position = 6^old_card_position mod 11:

This:     1,  2,  3,  4,  5,  6,  7,  8,  9, 10
Becomes:  6,  3,  7,  9, 10,  5,  8,  4,  2,  1

This works because 11 is prime, and 6 is a generator for the multiplicative group of integers mod 11, and mumble foo hah blibbity I can't do the explanation justice right now. But it works! And the pattern is a bit better hidden! Downsides: it only works for certain sizes of decks, and finding generators is a trial-and-error process.


Putting all practical concerns aside, I've discovered that I really enjoy thinking about these kinds of algorithms. I'm also aware of the limits of my own knowledge: it's really useful to talk to people who have studied different things!

So if you happen to have any suggested permutations, areas/topics for further study, or suggested reading/study material, I would be delighted to hear about them. My foray into discrete math has been mostly self-study, so I don't have a lot of context regarding where-to-look/what-to-read.

Thank you!

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/mr_bitshift
πŸ“…︎ Nov 29 2014
🚨︎ report
Unbounded Spigot Algorithms for the Digits of Pi, with Haskell code [PDF] web.comlab.ox.ac.uk/oucl/…
πŸ‘︎ 10
πŸ’¬︎
πŸ‘€︎ u/bardrey
πŸ“…︎ Mar 17 2007
🚨︎ report
Calculating E with a simple Spigot algorithm (javascript example in link at the end). mr23.posterous.com/mixed-…
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/g23f
πŸ“…︎ Jun 02 2011
🚨︎ report
SERIOUS: This subreddit needs to understand what a "dad joke" really means.

I don't want to step on anybody's toes here, but the amount of non-dad jokes here in this subreddit really annoys me. First of all, dad jokes CAN be NSFW, it clearly says so in the sub rules. Secondly, it doesn't automatically make it a dad joke if it's from a conversation between you and your child. Most importantly, the jokes that your CHILDREN tell YOU are not dad jokes. The point of a dad joke is that it's so cheesy only a dad who's trying to be funny would make such a joke. That's it. They are stupid plays on words, lame puns and so on. There has to be a clever pun or wordplay for it to be considered a dad joke.

Again, to all the fellow dads, I apologise if I'm sounding too harsh. But I just needed to get it off my chest.

πŸ‘︎ 17k
πŸ’¬︎
πŸ‘€︎ u/anywhereiroa
πŸ“…︎ Jan 15 2022
🚨︎ report
Blind Girl Here. Give Me Your Best Blind Jokes!

Do your worst!

πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Leckzsluthor
πŸ“…︎ Jan 02 2022
🚨︎ report
French fries weren’t cooked in France.

They were cooked in Greece.

πŸ‘︎ 9k
πŸ’¬︎
πŸ“…︎ Jan 20 2022
🚨︎ report
This subreddit is 10 years old now.

I'm surprised it hasn't decade.

πŸ‘︎ 14k
πŸ’¬︎
πŸ‘€︎ u/frexyincdude
πŸ“…︎ Jan 14 2022
🚨︎ report
You've been hit by
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/mordrathe
πŸ“…︎ Jan 20 2022
🚨︎ report
I'm sick of you guys posting dumb wordplay in here for awards and upvotes.

Don't you know a good pun is its own reword?

πŸ‘︎ 11k
πŸ’¬︎
πŸ‘€︎ u/diggitygiggitycee
πŸ“…︎ Jan 21 2022
🚨︎ report
My 4 year oldest favourit joke, which he very proudly memorized and told all his teachers.

Two muffins are in an oven, one muffin looks at the other and says "is it just me, or is it hot in here?"

Then the other muffin says "AHH, TALKING MUFFIN!!!"

πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/smoffatt34920
πŸ“…︎ Jan 22 2022
🚨︎ report
Dropped my best ever dad joke & no one was around to hear it

For context I'm a Refuse Driver (Garbage man) & today I was on food waste. After I'd tipped I was checking the wagon for any defects when I spotted a lone pea balanced on the lifts.

I said "hey look, an escaPEA"

No one near me but it didn't half make me laugh for a good hour or so!

Edit: I can't believe how much this has blown up. Thank you everyone I've had a blast reading through the replies πŸ˜‚

πŸ‘︎ 20k
πŸ’¬︎
πŸ‘€︎ u/Vegetable-Acadia
πŸ“…︎ Jan 11 2022
🚨︎ report
What starts with a W and ends with a T

It really does, I swear!

πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/PsychedeIic_Sheep
πŸ“…︎ Jan 13 2022
🚨︎ report
Why did Karen press Ctrl+Shift+Delete?

Because she wanted to see the task manager.

πŸ‘︎ 11k
πŸ’¬︎
πŸ‘€︎ u/Eoussama
πŸ“…︎ Jan 17 2022
🚨︎ report
Steve JOBS would have made a better President than Donald Trump

But that’s comparing apples to oranges

πŸ‘︎ 8k
πŸ’¬︎
πŸ‘€︎ u/Ok-Ingenuity4838
πŸ“…︎ Jan 22 2022
🚨︎ report
So 2 trees got arrested in the town I live...

Heard they've been doing some shady business.

πŸ‘︎ 7k
πŸ’¬︎
πŸ‘€︎ u/K1ll47h3K1n9
πŸ“…︎ Jan 18 2022
🚨︎ report
I was almost upset that my coffee tasted like dirt today

but then I remembered it was ground this morning.

Edit: Thank you guys for the awards, they're much nicer than the cardboard sleeve I've been using and reassures me that my jokes aren't stale

Edit 2: I have already been made aware that Men In Black 3 has told a version of this joke before. If the joke is not new to you, please enjoy any of the single origin puns in the comments

πŸ‘︎ 8k
πŸ’¬︎
πŸ‘€︎ u/scarf_spheal
πŸ“…︎ Jan 19 2022
🚨︎ report
How eggs-traordinary
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Rix27_
πŸ“…︎ Jan 21 2022
🚨︎ report
What is the scariest tree?

BamBOO!

πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/K1ll47h3K1n9
πŸ“…︎ Jan 18 2022
🚨︎ report
What is a a bisexual person doing when they’re not dating anybody?

They’re on standbi

πŸ‘︎ 11k
πŸ’¬︎
πŸ‘€︎ u/Toby-the-Cactus
πŸ“…︎ Jan 12 2022
🚨︎ report
A queen size statement.
πŸ‘︎ 4k
πŸ’¬︎
πŸ‘€︎ u/Flight-less
πŸ“…︎ Jan 22 2022
🚨︎ report
My ten-year-old daughter came up with this at dinner tonight: What do you get if put a copy of Macbeth on top of a dictionary?

A play on words.

πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/ah1887
πŸ“…︎ Jan 20 2022
🚨︎ report
My son, Luke, loves how I named our kids after Star Wars characters...

My daughter, Chewbecca, not so much.

πŸ‘︎ 8k
πŸ’¬︎
πŸ‘€︎ u/andersonfmly
πŸ“…︎ Jan 21 2022
🚨︎ report
Geddit? No? Only me?
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/shampy311
πŸ“…︎ Dec 28 2021
🚨︎ report
No gains
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/ridi86
πŸ“…︎ Jan 22 2022
🚨︎ report
I wanna hear your best airplane puns.

Pilot on me!!

πŸ‘︎ 3k
πŸ’¬︎
πŸ‘€︎ u/Paulie_Felice
πŸ“…︎ Jan 07 2022
🚨︎ report
E or ß?
πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/Amazekam
πŸ“…︎ Jan 03 2022
🚨︎ report
Which actor drives the least?

Christopher Walken

πŸ‘︎ 3k
πŸ’¬︎
πŸ‘€︎ u/TR1771N
πŸ“…︎ Jan 18 2022
🚨︎ report
I just flew in from Chernobyl

And boy are my arms legs.

πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/JhopkinsWA
πŸ“…︎ Jan 23 2022
🚨︎ report
What did Spartacus say when the lion ate his wife?

Nothing, he was gladiator.

πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/rj104
πŸ“…︎ Jan 15 2022
🚨︎ report
Pun intended.
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Sharmaji1301
πŸ“…︎ Jan 15 2022
🚨︎ report
No spoilers
πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/Onfour
πŸ“…︎ Jan 06 2022
🚨︎ report
Should we create an English word for the 'day after tomorrow'?

Or would that be too forward thinking?

πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/afunkysquirrel
πŸ“…︎ Jan 19 2022
🚨︎ report
These aren't dad jokes...

Dad jokes are supposed to be jokes you can tell a kid and they will understand it and find it funny.

This sub is mostly just NSFW puns now.

If it needs a NSFW tag it's not a dad joke. There should just be a NSFW puns subreddit for that.

Edit* I'm not replying any longer and turning off notifications but to all those that say "no one cares", there sure are a lot of you arguing about it. Maybe I'm wrong but you people don't need to be rude about it. If you really don't care, don't comment.

πŸ‘︎ 12k
πŸ’¬︎
πŸ‘€︎ u/Lance986
πŸ“…︎ Dec 15 2021
🚨︎ report
Covid problems
πŸ‘︎ 7k
πŸ’¬︎
πŸ‘€︎ u/theincrediblebou
πŸ“…︎ Jan 12 2022
🚨︎ report
Spi__
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/Fast_Echidna_8520
πŸ“…︎ Jan 11 2022
🚨︎ report
What did 0 say to 8 ?

What did 0 say to 8 ?

" Nice Belt "

So What did 3 say to 8 ?

" Hey, you two stop making out "

πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/designjeevan
πŸ“…︎ Jan 03 2022
🚨︎ report
I had a vasectomy because I didn’t want any kids.

When I got home, they were still there.

πŸ‘︎ 10k
πŸ’¬︎
πŸ‘€︎ u/demotrek
πŸ“…︎ Jan 13 2022
🚨︎ report
It is really unfortunate that Islam, Christianity, and Judaism have been fighting each other for centuries.

Hindus, on the other hand, never had any beef.

πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Utkarsh_Anand2004
πŸ“…︎ Jan 20 2022
🚨︎ report
I dislike karma whores who make posts that imply it's their cake day, simply for upvotes.

I won't be doing that today!

πŸ‘︎ 15k
πŸ’¬︎
πŸ‘€︎ u/djcarves
πŸ“…︎ Dec 27 2021
🚨︎ report
For Gotham
πŸ‘︎ 7k
πŸ’¬︎
πŸ‘€︎ u/FreeHugsXD
πŸ“…︎ Jan 17 2022
🚨︎ report
The Ancient Romans II
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/mordrathe
πŸ“…︎ Dec 29 2021
🚨︎ report
I did it, I finally did it. After 4 years and 92 days I went from being a father, to a dad.

This morning, my 4 year old daughter.

Daughter: I'm hungry

Me: nerves building, smile widening

Me: Hi hungry, I'm dad.

She had no idea what was going on but I finally did it.

Thank you all for listening.

πŸ‘︎ 17k
πŸ’¬︎
πŸ‘€︎ u/Sk2ec
πŸ“…︎ Jan 01 2022
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.