ポールHartrickのドット・コム






私が書いた最初のプログラム

2008年2月7日
2つのコメント
答えなさい
trackback

よい私の友人に応じての今日のポストはその「訳の分からない言葉」について私述べているか、または私の仕事の間に作成する常に尋ねている。 「訳の分からない言葉」は実際にいくつかに従って技術的な話のために「日本語-英語」である。 私は私が約14歳だったときに、これ私が私の最初コンピュータを購入したときであるすべてに戻って取らなければならない。 私の最初コンピュータはIBM 486または386ではなかった、また更に286は、私の最初コンピュータCasio PB-100だった。

私の最初PCの細部はここにある。

CasioのPB 100

PB-100は「実質の」小型コンピュータの方のCasioのステップを表す。 祖先間 FX-702P、まだ「プログラム可能な計算機」と、PB-100得意気に耐える」パーソナルコンピュータタイトルに「呼ばれた。

標準的な版では、それは実際に限っている、BASICのための544バイトだけで起因するRAMの1 KBが装備されている。 少なくとも、記憶モジュールOR-1と、それは1568のバイトのユーザーの記憶に改善することができる従ってBASICの記憶が10の独立したプログラム区域に細分することができるという意味を成し始める。

PB-100の主要な回路は2つの破片から基本的に成っている。 プロセッサーロジックス、ROM、表示運転者およびキーボード制御装置は外的な4ビットバスがある単一CMOS VLSIの破片HD61913で統合される。 第2主要なコンポーネントは4ビットにつき2048ワードとして組織される8192ビット静的なRAMのHD61914である。

私はロット、ラム、熱プリンターの1.5kの合計のための1kラムの改善を有し、それを言うこと不必要な磁気テープ装置は非常に強力なPCがほしいと思うが、することができる何が非常に動力不足のPCによって驚くたくわえの読書….

私の最初プログラムはBASICで書かれ、あなたが好むあらゆる数のFactorial計算できる。 何がFactorialであるか。 数学では、非負整数nのfactorial、nによって表示されて! 、n.と等しいかまたはそれ以下のすべての正整数のプロダクトはある。 例えば、5! = 1 x 2 x 3 x 4 x 5 = 120および6! = 1 x 2 x 3 x 4 x 5 x 6 = 720。 非常にすぐに非常に大きくなるために数を想像できるように。 ほとんどの計算機は、今日、69だけを管理できる! 、これは説明者が99を超過するポイントである。

従って私は問題を有した私が1,000,000を1,000,000のfactorialであるか何、解決したいと思う! 救助へのロガリズム。 している14歳の男の子は何でありあなたが頼むロガリズムを研究するか。 I guess thats a story for another post. After a few hours of reading a book, yes a book!( no internet in those days) I was able to establish that product of integers is the sum of their logs.

so 1 * 2 * 3 * 4 * 5 … is equal to exp( log(1) + log(2) + log(3)+ log(4) + log(5) )

Easy right… yeah right!

So I embarked on my first programming task. I was able to come up with a simple routine that broke the calculation down into small chunks easily handled by any programmable calculator or PC.

10 input x
20 for a = 1 to x
30 b = b + log10(a)
40 next a
50 c = b - frac(b)
60 d = b - c
70 e = 10 ^ d
80 print e , “E+” , c

Certainly not the best way to achieve the result by todays standards, and faced with many command restrictions,? still not to bad for a 14 year old boy.

You can still use this program today, go and download small basic and copy/paste the code and give it a try. It took more than 12 hours on my PB-100 to calculate 1,000,000!, now it takes about 1 second, I can now appreciate how much performance my laptop has, however my little program still beats the WindowXP calculator at Factorial.. try it and see.

So what is 1 million Factorial? 1,000,000! = 8.263930499EXP5565708, that 5.5 million zeros, give or take a few.

Now for all the other math heads who read this, I know it is an approximation as I am only using 16 significant digits, and there are more accurate ways to do this, blah blah blah, please remember I was only 14 at the time.

If you have managed to maintain interest and get to the end of this post, maybe your the type who can impress their friends with some geeky code.


This post is tagged , , ,

2 Comments

  1. Gil Hartrick

    Pauly, do you remember where you got the workings from ?…… It was me who brought the Swinburne Uni PC’s to a grinding hault in the early eighties with this Factorial Formulae on PUNCH CARDS… YES! punch card programming LOL

  2. Gil Hartrick

    Remember my Casio Calculator the FX-602P?? It computed 1,000,000 factorial in 4 minutes flat, not bad for a meek calculator

Incoming Links

Leave a Reply