Birthday Party

Mr. X's birthday is in next month. This time he is planning to invite N of his friends. He wants to distribute some chocolates to all of his friends after the party. He went to a shop to buy a packet of chocolates.

At chocolate shop, each packet is having different number of chocolates. He wants to buy such a packet which contains number of chocolates, which can be distributed equally among all of his friends.
Help Mr. X to buy such a packet.

Example:

Input:  n = 3, m = 21
Output: Yes

Approach

C++

#include <bits/stdc++.h>
using namespace std;

void birthdayParty(long long nlong long m)
{

    if (m % n == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}
int main()
{
    long long n = 3m = 21;

    birthdayParty(nm);

    return 0;
}


No comments:

Post a Comment