A challenge for all newbies

Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Reply

Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

A challenge for all newbies

 
0
  #1
Oct 31st, 2004
Find a six digit number that gives its digits reversed when multiplied by an integer between 2 and 9 inclusive. For example, if the original number was 654321 and the chosen integer was 8, then 654321 x 8 should equal 123456 if it was the magic number (which of course it doesnt). There are two (2) solutions.

Lets see who is the first to find out the exact numbers .... you can make a small program or you can do it MANUALLY :mrgreen: :evil:
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 12
Reputation: ALT-F4 is an unknown quantity at this point 
Solved Threads: 0
ALT-F4's Avatar
ALT-F4 ALT-F4 is offline Offline
Newbie Poster

Re: A challenge for all newbies

 
0
  #2
Oct 31st, 2004
109989-multplier is 9
219978-multiplier is 4
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: A challenge for all newbies

 
0
  #3
Nov 1st, 2004
wow ALT F4 ... you did it .. what algo did you use for it
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 12
Reputation: ALT-F4 is an unknown quantity at this point 
Solved Threads: 0
ALT-F4's Avatar
ALT-F4 ALT-F4 is offline Offline
Newbie Poster

Re: A challenge for all newbies

 
0
  #4
Nov 2nd, 2004
Nothing too fancy...
import java.io.*;
import java.awt.*;
import java.util.*;

public class NumberFinder {
    int test;
    int newNumber;
 
    public static void main(String[] args) {
       NumberFinder go = new NumberFinder();
    }
     public NumberFinder() {
    launch();
            
    }
     
    public void launch() {
    System.out.println("Starting to run");
        for(int i=100000; i<=999999; i++){
            for(int j=2; j<=9; j++){
                newNumber=reverse(i);
                if(i*j==newNumber){
                    System.out.println("The number is "+i+" and the multiplier is "+j);
                }
             }
        }
    }
       public int reverse(int x){
           String test = String.valueOf(x);
           String done = "";
           int run =5;
           int sendBack;
           while(run!=-1){
               done = done+test.charAt(run);
               run--;
           }
           sendBack = Integer.parseInt(done);
       return sendBack;
    }
    
}
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 12
Reputation: ALT-F4 is an unknown quantity at this point 
Solved Threads: 0
ALT-F4's Avatar
ALT-F4 ALT-F4 is offline Offline
Newbie Poster

Re: A challenge for all newbies

 
0
  #5
Nov 2nd, 2004
I appreciate the challenge by the way! It's nice to take a shot at something other than assigned homework, you know...
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: A challenge for all newbies

 
0
  #6
Nov 2nd, 2004
nice work ... I first reversed the number by modulus .. and then started off from 499999 .... in this way the processor had to do half the work . Your idea of reversing the number is also good.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 12
Reputation: ALT-F4 is an unknown quantity at this point 
Solved Threads: 0
ALT-F4's Avatar
ALT-F4 ALT-F4 is offline Offline
Newbie Poster

Re: A challenge for all newbies

 
0
  #7
Nov 3rd, 2004
Less operations is ALWAYS better. Do you mind posting your algorithm?? I'd like seeing a different solution.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: kirkchildress is an unknown quantity at this point 
Solved Threads: 0
kirkchildress kirkchildress is offline Offline
Newbie Poster
 
0
  #8
Nov 26th, 2004
[QUOTE=nanosani]Find a six digit number that gives its digits reversed when multiplied by an integer between 2 and 9 inclusive. For example, if the original number was 654321 and the chosen integer was 8, then 654321 x 8 should equal 123456 if it was the magic number (which of course it doesnt). There are two (2) solutions.

Lets see who is the first to find out the exact numbers .... you can make a small program or you can do it MANUALLY :mrgreen: :evil:[/QU1234567890
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: kirkchildress is an unknown quantity at this point 
Solved Threads: 0
kirkchildress kirkchildress is offline Offline
Newbie Poster

Re: A challenge for all newbies

 
0
  #9
Nov 26th, 2004
[QUOTE=kirkchildress]
Originally Posted by nanosani
Find a six digit number that gives its digits reversed when multiplied by an integer between 2 and 9 inclusive. For example, if the original number was 654321 and the chosen integer was 8, then 654321 x 8 should equal 123456 if it was the magic number (which of course it doesnt). There are two (2) solutions.

Lets see who is the first to find out the exact numbers .... you can make a small program or you can do it MANUALLY :mrgreen: :evil:
1234567890
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: kirkchildress is an unknown quantity at this point 
Solved Threads: 0
kirkchildress kirkchildress is offline Offline
Newbie Poster

Re: A challenge for all newbies

 
0
  #10
Nov 26th, 2004
1234567890
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Computer Science Forum


Views: 8364 | Replies: 29
Thread Tools Search this Thread



Tag cloud for Computer Science
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC