Thread: Greatest Multiple

  1. #1
    Registered User
    Join Date
    Feb 2016
    Posts
    14

    Greatest Multiple

    Let M (p,q,r,N) be the largest positive integer less than N or equal to N that has only p , q AND r as its distinct prime factors. ex 100(2,3,5)
    output = 90 because 2*3^2*5.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,665
    So where is your initial code effort?

    You can't just dump your question and hope we'll do all the work for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2016
    Posts
    14
    Code:
    #include <stdio.h>int main()
    {
        int d = 100, num=1;
        while(num < 10){
            if(num*5 < d){
                num*=5;
            }
            else if(num*3<d){
                num*=3;
            }
            else if(num*2<d){
                num*=2;
            }
            }
        
        printf("%d", num);
        return 0;
    }
    My apologies Salem

  4. #4
    Registered User
    Join Date
    Feb 2016
    Posts
    14
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    //John Raphael B. Pascua
    int main(){
        int a = 3,b = 7,c = 11,d = 1000000, e = a*b*c;
        while(e < d){
         if(e * c < d){
             e *=c;
         }else if (e * b < d){
             e *=b;
         }else if (e * a < d){
             e *=a;
         }
        }
        printf(" %d\n", e);
        return 0;
    }

  5. #5
    Registered User
    Join Date
    Feb 2016
    Posts
    14
    nvm just did it right hahaha thanks for always replying to all my posts salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Greatest Artwork Ever
    By the dead tree in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 01-28-2005, 06:53 PM
  2. The Greatest Musician Ever.
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-25-2003, 05:20 PM
  3. Greatest C++ Doubt
    By vasanth in forum C++ Programming
    Replies: 15
    Last Post: 02-28-2002, 04:41 AM
  4. Greatest Avatar :)
    By gamegod3001 in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 09-17-2001, 06:05 AM

Tags for this Thread