|
General Details
|
|
Scheme
|
|
Posted 131 Days Ago
|
|
278 Views
|
|
Received 1 Rating
|
|
Factoring numbers
Description
Here's a little program I made the factors a number into it's lowest prime factors. For example, factoring 100 gives use 2 * 2 * 5 * 5.
Source Code
Comments
| Please login to post comments. |
|
|
No no. It's a full language. Quite a good one too. It's small, simple, and can be very powerful.
|
|
|
Is Scheme actually a language with you can program, or is it a pseudo-language? I've never really looked into it.
|
|
|
The algorithm itself is very simple. The only thing that might confuse you is the Scheme syntax (especially if you've never used the language before).
The algorithm is simple:
def factor(num)
if num.is_prime?
num
else
make-a-list-with ( lowest-prime-divisor and (factor (num / lowest-prime-divisor) ) )
end
end
That's all there is too it. The Scheme code adds some cool things (like I'm actually returning a function, whos state contains a sieve of prime numbers).
|
|
|
That's very cool.. but totally foreign to me, lol! I don't even know if I can reproduce this in C#.. it would really take some time for to sit and think about it...
|
More "Scheme" Source Codes By This Author
Recently Posted "Scheme" Source Codes
Recently Rated "Scheme" Source Codes
|