LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

perfect numbers

I am suppose to create a VI that finds all perfect numbers less than 10,000. a perfect number is equal to the sum of its factors. example 6=1+2+3. There are 4 perfect numbers less than 10,000. I really have no idea how to start this. Any ideas.

 

Thank you

0 Kudos
Message 1 of 4
(2,740 Views)

Since you have been told to create a VI for this purpose, it sounds like this is an assignment from which you are to learn something.

 

Do you know how to calculate the factors of a number on paper? That is where I would start.  Although there may are fancy ways to factor numbers, I suggest starting with a brute force approach.  Simply loop through the 10000 numbers and calculate the factors and sums for each.

 

When you have more specific questions, post them, along with what you have tried, to get more help.

 

Lynn

Message 2 of 4
(2,725 Views)

Howdy cc26,

 

This looks like a pretty fun problem! What Lynn said above is a great approach. Definitely start by writing it out on paper and figuring out how you can translate that into code. It's difficult for us to give you the entire solution but we'd be more than willing to help with specific sections of the code that give you trouble.

 

Some useful things you might want to look into are the "Quotient & Remainder" function, auto indexing arrays using loops, and shift registers. These are some useful tools for solving a problem like this.

 

I hope your VI building goes well and that you have fun!

Tim A.
0 Kudos
Message 3 of 4
(2,664 Views)

A good way to start is do a quick web search for perfect number.

 

An intriguing pattern seems to be the fact that:

 

"Owing to their form, 2p−1(2p−1), every even perfect number is represented in binary as p ones followed by p − 1 zeros (p is a prime number)"

 

As long as you stay within the confines of 64bit integers, writing a program to get those seems trivial. What have you tried?

0 Kudos
Message 4 of 4
(2,659 Views)