hello buddy.how r u? i cant able to write a program to print first k
prfect number. perfect number is the sum of all factor less than equal
to tht number n which is equal to tht number,for example 6 is perfect
number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye
have a nice time.take care. 9 5565
"sej" <sw**********@yahoo.co.in> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... hello buddy.how r u? i cant able to write a program to print first k prfect number. perfect number is the sum of all factor less than equal to tht number n which is equal to tht number,for example 6 is perfect number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye have a nice time.take care.
i m ok, thx. sugg: do ur own hmwrk. and spk englsh
sej wrote: hello buddy.how r u? i cant able to write a program to print first k prfect number. perfect number is the sum of all factor less than equal to tht number n which is equal to tht number,for example 6 is perfect number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye have a nice time.take care.
See this FAQ and the one following: http://www.parashift.com/c++-faq-lit...t.html#faq-5.2
Cheers! --M
sej wrote: hello buddy.
I'm not your buddy.
how r u?
Pardon?
i cant able to write a program to print first k prfect number. perfect number is the sum of all factor less than equal to tht number n which is equal to tht number,for example 6 is perfect number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye have a nice time.take care.
So which part of that do you have problems with? Show us what you have so
far.
#include<iostream>
#include<conio.h>
int main()
{
int i=2;
int k=0;
while(k!=5) // say you want the first 5 perfect numbers
{
int sum=0;
for( int j=1;j<=i/2;j++)
{
if ((i%j)==0)
sum+=j;
}
if(sum==i)
{
cout<<"The number is perfect"<<sum<<endl;
k++;
}
i++;
} //
getch();
return 0;
}
Hey..sorry for the bad indendation. But it solves your purpose :)
zealot
sej wrote: hello buddy.how r u? i cant able to write a program to print first k prfect number. perfect number is the sum of all factor less than equal to tht number n which is equal to tht number,for example 6 is perfect number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye have a nice time.take care.
OK, well first you have to write a function which returns true if n is a
perect number and false otherwise.
bool is_a_perfect_number(int n)
{
...
}
and then you have to call it in a loop (maybe a for loop) so that you
call the function for successive integers.
Maybe you would need a few other functions such as, return true if a is
a factor of b.
bool is_a_factor(int a, int b)
{
...
}
Make sense so far? Well this is called programming, so have a go and if
you get stuck post your code back here.
john
Howard wrote: "sej" <sw**********@yahoo.co.in> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
hello buddy.how r u? i cant able to write a program to print first k prfect number. perfect number is the sum of all factor less than equal to tht number n which is equal to tht number,for example 6 is perfect number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye have a nice time.take care.
i m ok, thx. sugg: do ur own hmwrk. and spk englsh
His email address is from India.
--
Derek
"Derek Baker" <me@derekbaker.eclipse.co.uk> wrote in message
news:ad******************************@eclipse.net. uk... Howard wrote: "sej" <sw**********@yahoo.co.in> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
hello buddy.how r u? i cant able to write a program to print first k prfect number. perfect number is the sum of all factor less than equal to tht number n which is equal to tht number,for example 6 is perfect number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye have a nice time.take care.
i m ok, thx. sugg: do ur own hmwrk. and spk englsh
His email address is from India. -- Derek
So? I'm not commenting on poor grammar or poor spelling, but the use of
phrases like "how r u?", "tht" for "that", and no capitalization to start
sentences. Those are not factors of his being from India, they're IM-speak,
the shorthand that (mostly) kids are using on their text messagers, etc.,
and it's annoying. In a field such as programming, why use such shorthand?
You can't program in shorthand, and if you want to communicate with others,
it's best to be clear.
"At least that's my opinion... I could be wrong."
-Howard
Derek Baker wrote: Howard wrote: "sej" <sw**********@yahoo.co.in> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
hello buddy.how r u? i cant able to write a program to print first k prfect number. perfect number is the sum of all factor less than equal to tht number n which is equal to tht number,for example 6 is perfect number, and its factor is 1,2,3 and 1+2+3=6. try to help by tomm. bye have a nice time.take care.
i m ok, thx. sugg: do ur own hmwrk. and spk englsh
His email address is from India. -- Derek
So, what is that supposed to mean ? I am also from India. Please shed
some light on the cryptic sentence of yours.
The original post has nothing to do with the location. The fault lies
in the fact that 'sej' has used the same language he would have been
using in his IM world to post to a newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Charles Alexander |
last post by:
Hello
I am new to php & MySQL - I am trying to retrieve some records from a MySQL
table and redisplay them. The data in list form looks like this:
Sample_ID Marker_ID Variation
...
|
by: Anand Pillai |
last post by:
This is for folks who are familiar with asynchronous event handling in
Python using the asyncore module.
If you have ever used the asyncore module, you will realize that it's
event loop does not...
|
by: Gremlin |
last post by:
If you are not familiar with the halting problem, I will not go into
it in detail but it states that it is impossible to write a program
that can tell if a loop is infinite or not. This is a...
|
by: Martin Schou |
last post by:
Please ignore the extreme simplicity of the task :-) I'm new to C,
which explains why I'm doing an exercise like this.
In the following tripple nested loop:
int digit1 = 1;
int digit2 = 0;...
|
by: Toby Newman |
last post by:
At the page:
http://www.strath.ac.uk/IT/Docs/Ccourse/subsection3_8_3.html#SECTION0008300000000000000
or
http://tinyurl.com/4ptzs
the author warns:
"The for loop is frequently used, usually...
|
by: Alex |
last post by:
Compiler - Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland
Linker - Turbo Incremental Link 5.65 Copyright (c) 1997-2002 Borland
Platform - Win32 (XP)
Quite by accident I stumbled...
|
by: Ben R. |
last post by:
In an article I was reading
(http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/),
I read the following:
"The ending condition of a VB.NET for loop is evaluated only once,...
|
by: cj |
last post by:
When I'm inside a do while loop sometimes it's necessary to jump out of
the loop using exit do. I'm also used to being able to jump back and
begin the loop again. Not sure which language my...
|
by: Claudio Grondi |
last post by:
Sometimes it is known in advance, that the time spent in a loop will be
in order of minutes or even hours, so it makes sense to optimize each
element in the loop to make it run faster.
One of...
|
by: ADezii |
last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |