# Looping Question

Page 1 of 1

## 1 Replies - 684 Views - Last Post: 22 August 2013 - 02:49 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=327514&amp;s=52dea0c6bbfa1e15fd44bf27f3c47bdb&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 kyle_denney

Reputation: 0
• Posts: 171
• Joined: 10-August 12

# Looping Question

Posted 22 August 2013 - 02:42 PM

I am trying to find the easiest way to do the following:

I have pseudo-code but think it needs some optimization.

The pseudo-code I think one could use is something like this

```Dim resultNeeded = 123

Dim x = 0
Dim y = 0

For x as int16 = 0 to 1000
For y as int16 = 0 to 1000

Perform some quick calculation in here to get resultNeeded

Next
Next

```

What is inside the loop does not matter. What I am wanting to know is to see if the above loop is the best way to iterate through the two combinations of 1000 or is there a quicker way in VB.Net or C#. Thanks!

Basically set up two variables x, y such that each number is iterated through a loop all the way up to 1000 for both x and y running an algorithm on the result to see if it matches a certain criteria.

I am trying to run an algorithm that when using two numbers between 0-1000 will give a certain output - lets say a key like ACD123-45232.

All I am wanting to know is how to iterate through the two sets of 0-1000 the fastest way and run the algorithm through each iteration to test if it matches the value like above. The algorithm doesn't matter and I know in VB.Net you can use a For Each/Next scenario taking each number and looping it against the other number but I feel there has to be a better way. Any advice is appreciated. Thanks! - Remember any actual code is VB.Net or C#. Thanks!

Is This A Good Question/Topic? 0

## Replies To: Looping Question

### #2 modi123_1

• Suitor #2

Reputation: 14097
• Posts: 56,497
• Joined: 12-June 08

## Re: Looping Question

Posted 22 August 2013 - 02:49 PM

Yes.. that would be the most straight forward. So.. trying to brute force a key? Office product keys?