取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
1 条消息(共 4 条)
3,500 次查看

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

2 条消息(共 4 条)
3,485 次查看

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 项奖励
3 条消息(共 4 条)
3,424 次查看

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 项奖励
4 条消息(共 4 条)
3,419 次查看