| | |
Ruby: Count to 1 Billion, basing from a C++ Code
Please support our Ruby advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
How long does it take to count 1 billion?
Determine the amount of time it takes the program.
to complete in your programming environment, for N=1000, and 1000. If your compiler has optimization features that are supposed to make a program more efficient, check whether or not they do for this program.
However, this code below was the cheapest and the cheating way to fulfill how long will it count to 1Billion.
Note, this is my first time to get up close and personal with Ruby, not just the Ruby in RPG Maker XP.
Determine the amount of time it takes the program.
Ruby Syntax (Toggle Plain Text)
Int i,j,k, count=0; For (i=0; i<N; i++) For (j=0; j<N; j++) For (k=0; k<N; k++) count++
to complete in your programming environment, for N=1000, and 1000. If your compiler has optimization features that are supposed to make a program more efficient, check whether or not they do for this program.
However, this code below was the cheapest and the cheating way to fulfill how long will it count to 1Billion.
Ruby Syntax (Toggle Plain Text)
for k in 1..1000000000 print k," " end print "\n"
Note, this is my first time to get up close and personal with Ruby, not just the Ruby in RPG Maker XP.
![]() |
Similar Threads
- Anyone want to learn Ruby (Ruby)
- I'm looking for words counter code (VB.NET)
- [Need Help] shell scripting count data in files (Shell Scripting)
- Comparing two letters in one string with another char string? (C)
- Need help with Random Divs code (PHP)
- How to count Uppercase Letter from a String (ASP)
- count (C++)
- critical count for quicksort?? (C)
- Help with error checking code (C++)
Other Threads in the Ruby Forum
- Previous Thread: WSDL and ruby
- Next Thread: How to change the server port number in redmine
| Thread Tools | Search this Thread |





