Explore BrainMass
Share

# Algorithm to generate an increasing sequence of integers

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Design an algorithm to generate the sequence of positive integers (in increasing order) whose only prime divisors are 2 and 3; that is, your program should produce the sequence 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, ... . Does your program represent an algorithm in the strict sense?

https://brainmass.com/computer-science/programming-languages/algorithm-generate-increasing-sequence-integers-338455

#### Solution Preview

A strict algorithm must stop in a finite time. Since "the sequence of positive integers..." has no end (it is infinite), no algorithm in the strict sense can produce it. We could head in the direction of something producible by a strict algorithm by changing the requirement to something like "the sequence of positive integers less than or equal to 200..."

How do we know that the given sequence is infinite? Let us assume, it is not. Then, there is a greatest number ...

#### Solution Summary

A SQL algorithm to generate the increasing sequence of positive integers whose only prime divisors are 2 and 3. The version will run in SQL 2008 or any edition that supports the += operator. The algorithm can serve as a basis to other SQL languages and implementations or work as pseudo-coded in other contexts.

Comment is made on whether this solution can be considered an algorithm in the strict sense.

\$2.19

## C++ Code for Testing Random Number Generator

I am using "Numerical Recipes (3rd Edition)" to create a numerical method that computes random numbers. My problem is that I'd like to use tests such as Chi-Square to test the uniformity/performance of the generator, but I don't know how to do this.

You can see my basic number generator in the readable file randomnumbers. I've included portions from "Numerical Recipes" (which you can easily find on Scribd) on random numbers and statistical functions. Based on the structure of the codes, I need help writing a program that uses Chi-Square (or something else appropriate from statistical functions.pdf) to test my random number generator.

I am extremely new to c++, so if my bid is too low please let me know. I'm not sure how long the necessary code will be or how much expertise it will require, so I don't know how much you will charge.

In case you can't read my cpp code, it's very basic:

#include <iostream>
#include "/Users/.../Documents/NR/code/nr3.h"
#include "/Users/.../Documents/NR/code/ran.h"

int main(){
Int seed = 12345678;
Ran myran(seed);
for(int i=0;i<10;i++){
cout<<"Using ran = " << myran.doub() <<endl;
}
return 0;
}

and returns 10 random numbers. This is just an example, it probably isn't my final code, just something simple for you to see what I'm going for. Please note that I am very weak with c++ and really don't know much about what I'm doing.

View Full Posting Details