Welcome, Guest. Please login or register.
Did you miss your activation email?
Pages: [1]   Go Down
  Print  
Author Topic: Factorial with BigInt class, simple as working with primitive types  (Read 1023 times)
0 Members and 1 Guest are viewing this topic.
jurka
Moderator
Member
*
*

Reputation: 5
Offline Offline
Posts: 188
Referrals: 0

Awards
« on: August 10, 2009, 05:10:45 AM »

It's really easy to use the Scala's type system, BigInt or whatever type you would want to make it as part of the work is easy. If anyone have time to make the Java's version of this, it would be nice for comparing.

Code
GeSHi (java):
  1. object Factorial {
  2.  
  3.  def fact(n: BigInt): BigInt = {
  4.    if (n == 0) 1 else n * fact(n - 1)
  5.  }
  6.  
  7.  def main(args : Array[String]) : Unit = {
  8.    println(fact(150))
  9.  }
  10. }
Created by GeSHI 1.0.7.20
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2593
Referrals: 13

WWW Awards
« Reply #1 on: August 10, 2009, 05:38:47 AM »

Wow, the scala guru wrote a post here after ages. Glad you're back to impress us with more Scala related posts. I'll write a Java version later to compare. rep++ given.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
jurka
Moderator
Member
*
*

Reputation: 5
Offline Offline
Posts: 188
Referrals: 0

Awards
« Reply #2 on: August 10, 2009, 10:04:10 AM »

Ty ill try to make more posts here, if not so Scala related but certainly functional language topics.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here