Also whats unsloved about weird numbers?
Main Topics
Browse All TopicsI stumble into a math problem yesterday..Weird Number.
One of my friend said that it's impossible to come up with the source code to generate the weird number because weird number is a unsolved maths mystery... but... i doubted him
so help me proved him wrong.....
here's somthing about weird number...
a weird number is an integer say...n for which:
1.the proper divisors of n sum to a number larger than n; and also
2.n cannot be expressed as the sum of a subset of its proper divisors.
As an example, consider n=12. The divisors are 1, 2, 3, 4, 6, and 12. The proper divisors of a number are the divisors of n exluding n itself. Thus the proper divisors of 12 are 1, 2, 3, 4, and 6. These sum to 16 so the first condition is satisfied. However, the second condition is not satisfied because:
12 = 1 + 2 + 3 + 6
so 12 can be expressed as the sum of a subset of its proper divisors. Therefore 12 is not a weird number.
For the case of n=70, the proper divisors of 70 are 1, 2, 5, 7, 10, 14, and 35. The first condition is satisfied becasuse these sum to 74, which is greater than 70. The second condition is satisfied because there is no subset of the proper divisors that sums to exactly 70. Therefore 70 is a weird number
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Try this:
//weird.cpp
#include<iostream>
#include<vector>
using namespace std;
typedef vector<int, allocator<int> > INTVECT;
#include"numclass.h"
INTVECT vects(9000);
INTVECT vects2(9000);
Properdiv::Properdiv()
{
}
Properdiv::Properdiv(int i)
{
num=2;
int ibackup=i;
float test2;
float devi=i;
int test;
int v=0;
do{
test=i/num;
test2=devi/num;
if(test==test2)
{
v++;
vects[v]=test;
}
num++;
}while(num!=i+1);
}
Properdiv::~Properdiv()
{
}
void main()
{
int global=0;
int numofglobal=0;
int t=0;
int backupt;
int last=0;
cout<<"Enter number to start looking for wierd numbers at"<<endl;
cin>>t;
cout<<"Enter the last number to check"<<endl;
cin>>last;
do
{
int flags=0;
int t3=0;
int z;
int comp=0;
int numof=0;
int testiswierd=0;
int testiswierd2;
backupt=t;
Properdiv div(t);
t=backupt;
for(z=0;z<t;z++)
{
if(vects[z]==comp)
{
comp=vects[z];
}
else
{
numof++;
comp=vects[z];
}
}
numof--;
z=0;
for(int i=0;i<=numof;i++)
{
testiswierd=testiswierd+ve
}
testiswierd2=testiswierd-t
for(int i2=0;i2!=numof;i2++)
{
t3=vects[i2];
if(t3==testiswierd2)
{
flags=1;
}
}
if(flags==1)
{
}
else
{
vects2[global]=t;
global++;
numofglobal++;
}
t++;
}while(t<last);
cout<<"These are weird numbers"<<endl;
for(int i3=0;i3!=numofglobal;i3++)
{
cout<<vects2[i3]<<endl;
}
int ahh;
cin>>ahh;
}
//weird.h
class Properdiv
{
private:
int num;
public:
Properdiv();
Properdiv(int i);
~Properdiv();
};
I think this should work.
Compile and give it a try.
NPC is Non Polynomial (Complete). I think that what yair ment was NP. It means that the algorithm takes exponential time to finish the calculation.
About your code: Have you checked it?
I could not compile it in my machine, and I think it does not check all the posibilities:
1. You did not put 1 as proper devisor.
2. I don't think you are passing in the inner loop on all the possible devisors sums.
Yair:
It is possible to check many less than all the subsets of the devisors. Since thay are ordered, certain subsets may not be checked.
I can try write more efficient code, if babyruth would ask.
Fuzzy
about our NP - NPC dicastion:
today we learned that proberly NP != NPC but noboday knows
for sure, they might be the same.
what is special about NPC is that it a family
inside NP problems that you can do redaction with Polynomial cost from one problem to another...
(so if one is solved in P - all will be)
that was 60 seconds on NP and NPC ....
Yair
:)
Business Accounts
Answer for Membership
by: laeuchliPosted on 1999-06-02 at 21:49:27ID: 1262221
I don't get what you want me to do. Do you want me to get some code that check if a number is a weird number? Do you want me to write code that trys to get weird numbers?
Please write back.