#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,sum;
clrscr();
for(i=1;i<=500;i++)
{
j=1;
sum=0;
while(j<i)
{
if(i%j==0)
sum=sum+j;
j++;
}
if(sum==i)
printf("%d\n",i);
}
getch();
}
k
no thanks
You can use the Math.sqrt() method.
To find perfect numbers between 1 and 50 in a C program, you can iterate through each number in that range and check if it is equal to the sum of its proper divisors. A perfect number is defined as a number that is equal to the sum of its positive divisors, excluding itself. Here's a basic outline of the program: #include <stdio.h> int main() { for (int num = 1; num <= 50; num++) { int sum = 0; for (int i = 1; i <= num / 2; i++) { if (num % i == 0) sum += i; } if (sum == num) printf("%d is a perfect number\n", num); } return 0; } This code checks each number from 1 to 50 and prints out the perfect numbers found in that range.
create a program that iterates until it finds a perfect number, then store that perfect number into an array. Continue iterating until you find three more. Then, you have an array of four perfect numbers.
Yes, do write, or if you're too lazy to your homework, use google.
Write your own prime number program and find out.
1. Get any no. 2. Find it factors. 3. Add its factor. 4. If sum of its factors is equal to itself then it is a perfect no. otherwise not
Write a program to find the number and sum of all integers from 100 to 300 that are divisible by 11
write a vb program to find the magic square
For first find an example program.
Write a program to find the grade obtained by the students of a class