| | |
c++ I did not understand
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 5
Reputation:
Solved Threads: 0
I have a question I did not understand if anyone of you understood it please explain to me
suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n if n=mt for some integer t; that is, when m divides n, the remainder is 0. moreover .m is called a proper divisor of n if m<n and m divides n. a positive integer is called perfect if it is the sum of its positive proper divisors. for example, the positive proper divisors of 28 are 1,2,4,7 and 14 and 1+2+4+7=28. therefore 28 is perfect. write a program that does the following;
a.output the first four perfect integers.
b.takes as input a positive integer and then outputs whether the integer is perfect.
and thank you a lot
suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n if n=mt for some integer t; that is, when m divides n, the remainder is 0. moreover .m is called a proper divisor of n if m<n and m divides n. a positive integer is called perfect if it is the sum of its positive proper divisors. for example, the positive proper divisors of 28 are 1,2,4,7 and 14 and 1+2+4+7=28. therefore 28 is perfect. write a program that does the following;
a.output the first four perfect integers.
b.takes as input a positive integer and then outputs whether the integer is perfect.
and thank you a lot
•
•
Join Date: Jul 2005
Posts: 1,688
Reputation:
Solved Threads: 265
Do you have a problem with the math involved or the C++ involved? The easiest way to do the math you need using C++ is to use the modulo operator. Assuming m and n are both postive integers, if the result of m % n is zero then, n is a positive proper divisor of m according to the description you provided.
Klatu Barada Nikto
•
•
•
•
I have a question I did not understand if anyone of you understood it please explain to me
suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n if n=mt for some integer t; that is, when m divides n, the remainder is 0. moreover .m is called a proper divisor of n if m<n and m divides n. a positive integer is called perfect if it is the sum of its positive proper divisors. for example, the positive proper divisors of 28 are 1,2,4,7 and 14 and 1+2+4+7=28. therefore 28 is perfect. write a program that does the following;
a.output the first four perfect integers.
b.takes as input a positive integer and then outputs whether the integer is perfect.
and thank you a lot
well ur inputted with a number for ex lets take the no 28 ( which is in ur ex)
1. (this one is for proper divisor )
u will have to find such nos that divide 28 completely i.e
28 % number = = 0
the remainder must be zero
thus you will land up in 1 , 2, 4, 7 , 14
2. then when u find these numbers , u will have to find the summation of these in such a manner that
their sum is equal to 28
i.e in this case 1+2+4+7+14 = 28
thus the number 28 becomes perfect positive number .
<?php
$data = $_POST['data'];
if(empty($data)) {
echo "byte me" ; }
?>
$data = $_POST['data'];
if(empty($data)) {
echo "byte me" ; }
?>
it means that if you divide n by m, the division should leave no remainder.
>>we have to use if in these statement (m!=0)(m%n==0)(m<n) right??
yes
>>and we don't need to use loop, right??
No
You will have to use the loops for the first part of the question
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
well let me simply for you ..
1. accept number(`s in form of for loop or so ) and perfrom step 1 of my previous post .
you will land up with alll the divisors of that particular number (which will be the current number of for loop ) .
store it in some kinda array .
2. now check the summation of these numbers (which are divisors of the number inputted). if the add up to the number which is inputted , then the number which is inputted is perfect .
now re run the for loop and find such first 4 perfect numbers
1. accept number(`s in form of for loop or so ) and perfrom step 1 of my previous post .
you will land up with alll the divisors of that particular number (which will be the current number of for loop ) .
store it in some kinda array .
2. now check the summation of these numbers (which are divisors of the number inputted). if the add up to the number which is inputted , then the number which is inputted is perfect .
now re run the for loop and find such first 4 perfect numbers
<?php
$data = $_POST['data'];
if(empty($data)) {
echo "byte me" ; }
?>
$data = $_POST['data'];
if(empty($data)) {
echo "byte me" ; }
?>
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 1
can u please give us the full program for this question
"suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n=mt for some integers t; that is when m divides n, the remainders is 0,moreover,m is called a proper divisor of n if m<n and m divides n .a positive integers is called perfect if it is the sum of its positive proper divisors .for example the positive divisor of 28 are 1,2,4,7 and 14 and 1+2+4+7+14=28,thrfore 28 is perfect write a program that does the following :a)output the first four perfect integers b)takes as input a positive integers and then outputs whether the integers is perfect"
"suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n=mt for some integers t; that is when m divides n, the remainders is 0,moreover,m is called a proper divisor of n if m<n and m divides n .a positive integers is called perfect if it is the sum of its positive proper divisors .for example the positive divisor of 28 are 1,2,4,7 and 14 and 1+2+4+7+14=28,thrfore 28 is perfect write a program that does the following :a)output the first four perfect integers b)takes as input a positive integers and then outputs whether the integers is perfect"
•
•
•
•
well let me simply for you ..
1. accept number(`s in form of for loop or so ) and perfrom step 1 of my previous post .
you will land up with alll the divisors of that particular number (which will be the current number of for loop ) .
store it in some kinda array .
2. now check the summation of these numbers (which are divisors of the number inputted). if the add up to the number which is inputted , then the number which is inputted is perfect .
now re run the for loop and find such first 4 perfect numbers
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 1
please help me to get the full program for writing this question
"suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n=mt for some integers t; that is when m divides n, the remainders is 0,moreover,m is called a proper divisor of n if m<n and m divides n .a positive integers is called perfect if it is the sum of its positive proper divisors .for example the positive divisor of 28 are 1,2,4,7 and 14 and 1+2+4+7+14=28,thrfore 28 is perfect write a program that does the following :a)output the first four perfect integers b)takes as input a positive integers and then outputs whether the integers is perfect"
"suppose that m and n are integers and m is nonzero. Recall that m is called a divisor of n=mt for some integers t; that is when m divides n, the remainders is 0,moreover,m is called a proper divisor of n if m<n and m divides n .a positive integers is called perfect if it is the sum of its positive proper divisors .for example the positive divisor of 28 are 1,2,4,7 and 14 and 1+2+4+7+14=28,thrfore 28 is perfect write a program that does the following :a)output the first four perfect integers b)takes as input a positive integers and then outputs whether the integers is perfect"
•
•
Join Date: Jul 2005
Posts: 1,688
Reputation:
Solved Threads: 265
C++ Syntax (Toggle Plain Text)
input n vector<int> factors for(int i = 2; i <= n/2; ++n) //check if i is factor of n //if it is add it to the vector //declare variable to act as running total and initalize to zero //loop through vector adding elements together for(int i = 0; i < size of vector; ++i) //add each element to previous total //if n equals total from above loop, then n is a perfect number.
Klatu Barada Nikto
![]() |
Similar Threads
- Code for Call the program in Visual Basic (Visual Basic 4 / 5 / 6)
- Help me understand function in c++ (C++)
- Help me understand Pointers (C++)
- help me understand end of do while loop (C++)
- file sharing. help!!! dont understand!! (Networking Hardware Configuration)
- don't understand (C++)
- Creating a locking program (C)
Other Threads in the C++ Forum
- Previous Thread: STL beginner needs helps
- Next Thread: Make base pyramid
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






