Largest prime factor of a composite number

The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?

Prime factors are prime numbers that can be multiplied together to make a given number. One way to find them is to start by dividing the number by the first prime (2) and continuing to do so until it cannot be divided, then moving on to the next.

Module Module1
  Sub Main()
    Dim beganAt As Date = Now
    Dim n As Long = 600851475143
    Dim factor As Integer = 2
    Dim highestFactor As Integer = 1
    While n > 1
      If n Mod factor = 0 Then
        highestFactor = factor
        n = n / factor
        While n Mod factor = 0
          n = n / factor
        End While
      End If
      factor = factor + 1
    End While
    Dim endAt As Global.System.TimeSpan = Now.Subtract(beganAt)
    Dim took As Integer = endAt.Milliseconds
    Console.WriteLine(highestFactor.ToString + " in " + took.ToString + "ms.")
    Console.ReadKey()
  End Sub
End Module

Finally succeeding?

I read an article by James Somers at The Atlantic called “How I Failed, Failed, and Finally Succeeded at Learning How to Code“. I’d encourage anyone with an interest in learning to code to read it – he discusses how computer programming is an excellent learning experience but that his own experiences have been tempered by poor instruction, particularly from books. He goes on to discuss how Project Euler became the titular success.

Euler provides a series of programming challenges of increasing difficulty, as the student solves each in turn they gain experience of what does and does not work as well as confidence in their abilities. Importantly, the student is also applying programming to practical problems (if you’re a mathematics student) from the outset.

I’ll post my solutions here as I go. I’m aiming to do one a day but I’ll see how I get on. Not sure what language is best to get on with, Python is popular in open source circles but most of my courses are based around Java.

 

Completing BSc (Honours) Computing and IT

With ten years remaining in my contract and the government’s intentions unclear, I’ve decided to get my finger out and focus on completing the BSc (Honours) Computing and IT (B62). It can use 120 points from four completed modules – M150T175MST121 and M255 as well as 30 points from MS221, which I have already started.

At level two I’m taking two courses on top of MS221 which I intend to study concurrently, so as to be half way through by the end of next year:

  • T215 – Communication and information technologies (60)
  • MT264 – Designing applications with Visual Basic (30)

Leaving 120 points at level 3:

  • M359 – Relational databases: theory and practice (30)
  • M364 – Fundamentals of interaction design (30)
  • M366 – Natural and artificial intelligence (30)
  • TM470 – The computing and IT project (30)

TU100 Café

I’ve submitted T175‘s EMA and I don’t mind saying its a relief. Although not a difficult module, the OU changed the Computing degree structure introducing TU100, replacing T175 and M150 (which I did several years ago). Along with MST121 I had thought that I had my level one courses out of the way but with the changes, I needed to take T175.

This course used Moodle forums rather than FirstClass. This seems to have been a lot more accessible to new students and the Café in particular has proved popular. The Open University have kindly asked me to be one of the moderators in the Café on TU100. It came as quite a surprise – I hope I make a good job of it!

Calculators

I’ve just started a maths course (MS221 with The Open University). I completed MST121 with a cheap Casio FX991 calculator (it cost about £15).

The time has come to buy something a bit more, well grown up. I’ve been looking at offerings from TI and HP. I’m kind of leaning towards an HP 50g. I can’t make up my mind so I thought I’d throw it out there and see what people recommend. The course says any calculator is allowed provided it doesn’t need plugged into the mains, doesn’t have a QWERTY (or local equivalent) keyboard and can’t communicate with other calculators.

Ideally it should be able to connect with Ubuntu – the HP has an SD card but I don’t know about TI.

 

Twitter vulnerabilities, using Windows, studying and new WordPress themes.

Graham Cluley, a Senior Technology Consultant at Sophos, has a nice blog piece on the Twitter worm from earlier this week. To cut a long story short, he reminds us of the importance of sanitizing inputs.

Still, it was more productive than my week with my Open University module that starts in October – T175 (Networked living: exploring information and communication technologies). The OU can be very Windows dependent but this course seems to be pretty much delivered in Virtual Learning Environment (what the OU calls Moodle). I ran the course DVD, which is a Windows Flash standalone thing which got me to revive the OU Ubuntu Users group, sending out emails, starting a mailing list and trying to get things going again.

So why was it unproductive? Well, I haven’t booted Windows in ages – there were a million updates, one of which was for the wireless driver. Update completely borked the wireless and I wound up restoring the drive. That aside, one thing I really like about Ubuntu (and most distributions) is a centralised update manager – Windows has Adobe, Java, Windows Update, Firefox and McAfee all trying to pull updates at the same time. It makes the system completely unusable for the first ten minutes it’s on!

Any way, I decided to build a new WordPress theme. Same colour scheme, more rounded edges – should be available in the next few days.

Study

When I was younger, I couldn’t have cared less about education. I didn’t like school and accordingly education could whistle.

As I got into my late teens, I discovered that if a subject interested me I could study it and study it to a greater depth than was required to pass exams. I enjoyed university, working alongside others with similar interests and broadening my knowledge.

Now in my thirties, I have been studying for a degree in a named subject and have lost sight of the pleasure of learning. I’m not interested in every aspect of the current degree I am studying (B49). In particular, I have found a great deal of the Java development a pointless chore. Don’t get me wrong – I have nothing against Java. It just seems to have been a lot of learning with no tangible results, I mean I haven’t really developed anything.

I’ve been looking over the Open University’s prospectus for 2010. I think I might want to try something I’m interested in – so am considering a Certificate in Legal Studies or a Certificate in French. Then again, Mandarin Chinese might be interesting.

Is it a good idea to step out of an ascribed program at this stage though? Who knows and who cares. Learning should be fun.

Exploring Psychology

The course material for DSE 212 just arrived. Once I’d got over the weight of the package, I opened it to discover that it consists of a number of large text books, a couple of DVD, CDs, software and the usual assorted paraphernalia – part threes, course updates and errata. Looking over the course material, it seems well structured and nicely presented. The study calendar would suggest that this is going to be intensive, with the first TMA due on the 11th November.

If you’re still reading – you might wonder what this has to do with Ubuntu. Well it comes down to the course software – a large part of the course is centred around the data mining software SPSS. Now of course you might well suggest free alternatives such as R or PSPP, indeed PSPP is intended as a replacement and is very similar. It’s not the same however and the big difference is that the course material is geared to step by step work in SPSS version 14.

The version is important, from what I can ascertain – SPSS version 17 is available for Linux. IBM has acquired the company so this may well continue. That said, version 14 is what has been supplied. This is not uncommon with the OU – MST121 for example uses Mathcad 2000.

Now, how about running in Wine you might say – the software has a little license validation applet that doesn’t seem to agree with Wine but I might be doing it wrong. However, for many studying is already expensive – why should it also involve complicating installation?

It has been suggested the Open University is not at all open to open source software. I don’t know if this is a policy or not but I do know that the Windows based software they supply is outdated. I can understand that this is probably for the same reason that Linux is not supported – that it would mean making substantial changes to the course material.

Course tutors I have spoken to have been extremely favourable to the idea of packaging software for Ubuntu and distributing it with course material. There are issues here, licensing and maintaining spring to mind – no to mention support. There is no way the OU Computing Helpdesk are going to support Ubuntu so that leaves the community.

Where does one draw the line between the desire to use open source software and the ease of using a provided solution? Am I putting myself at a disadvantage to my peers? Although I am confident with statistics, I’m effectively learning two systems as the course teaches one and I apply it to another system. Even if this entails five minutes an assessment, it’s five minutes that Windows users are excused. Moreover I’ve paid for it through course fees, can I get that refunded?

What surprises me is that the OU is about accessibility – anyone can study with them, except it would seem those who choose not to use Windows. Shouldn’t the Open University be Open?