Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Prime number



  A Perl Regular Expression That Matches Prime Numbers

perl -lne '(1x$_) =~ /^1?$|^(11+?)\1+$/ || print "$_ is prime"' Can you figure out how it works? I give an explanation below, but try to figure it out yourself. Here is what happens when you run it: $ perl -lne '(1x$_) =~ /^1?$|^(11+?)\1+$/ || print "$_ is prime"' 1 2 2 is prime 3 3 is prime 4 5 5 is prime 6 7 7 is prime 8 9 10 11 11 is prime Here is how it works. First, the number is converted in its unary representation by (1x$_). For example, the number 5 gets converted into 1x5, which is ...

   Perl,Regex,Regular expression,Prime number,One line     2011-12-26 08:42:00

  Generate first N prime numbers

Recently I am taking an online course named "Startup Engineering" on coursera. There is one assignment which is to use NodeJS to write a program to generate the first 100 prime numbers. This may be very easy for many people. Here I just want to share with you the code to generate not only the first 100 prime numbers. but also any number of prime numbers. Below is the code snippet: //Helper class to generate prime numbers var PrimeProcessor=(function(){ var primeArray=[]; functio...

   Algorithm,Prime number,NodeJS,coursera,JavaScript     2013-06-29 22:08:22

  Microsoft Interview Riddle Questions

Every year, many people will send their resume to Microsoft and Google. So how do these IT companies hire people? What kind of interview questions will they ask. Let's see what Microsoft asked before in this article. These questions are more focusing on how you are reasoning, not necessary your technical skills. 1.  You’ve got someone working for you for seven days and a gold bar to pay them. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at...

   Microsoft,Interview question,Riddle questions,Answer     2012-03-10 04:56:48

  Collection Of Puzzles For Programmers

Did you know that we have a nice collection of puzzles here on less than dot? Some are harder than others so there is something for everyone. You can pic any language you want, you will see that there are solutions in Ruby, Python, Visual Basic, SQL, JavaScript, C++ and other. Here is a partial list of what we have Friday the Thirteenths The goal is to identify all friday the thirteenths for a given timeframe Regular Pentagon Given a grid co-ordinate (x,y) as the centre point of a regu...

   Programming puzzle,Fibonacci,Prime,ASCII     2012-01-04 08:06:18

  World leaders who know how to code

World leaders are those people who have extraordinary speaking skills and are a group of very busy people in most people's impression. But among them, there are a few who know how to program as well. Today we are going to summarize some of them. Lee Hsien Loong -- Singapore Prime Minister Lee Hsien Loong, Singapore Prime Minister posted a C++ program about Sudoku which he wrote several years ago. He shared the source code on Google Drive as well.  In 1971, Mr. Lee studied Mathema...

   World leader, Coding, Programming     2015-08-02 05:56:20

  Spending Too Much on Your Streaming Services? Read This

Remember the times when we thought ditching the cable TV might be a good idea to save time as well as all that money? Little did we know that platforms like Netflix, Hotstar, Hulu, HBO, Paramount, Disney Plus, and Apple TV Plus together cost more than the cable alone.  On the brighter side, there are ways to curb your streaming costs without much sacrifice. Do you want to binge-watch all your favorite shows at much fewer costs? Read on some great tips to save all that streaming costs to wa...

   NETFLIX,STREAMING     2022-06-13 07:20:37

  Write Scalable, Server-side JavaScript Applications with Node.js

If you live in the Silicon Valley area, you have already heard the buzz: Node.js is being hailed as the next big thing. It’s the silver bullet that offers scale, eases development, and can be leveraged by the vast pool of client-side JavaScript developers. So, what exactly is Node.js?Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. It is based on Google's V8 JavaScript engine plus several built-in libraries. The excitement around Node.js is tha...

   Node.js,Server side,Scalable,JavaScript app     2012-03-29 13:50:50

  Add page number anywhere in word document

Have you ever frustrated when you want to add page number in a Microsoft word document start from page 2 or later. The way to ease you is to add sections to the word document in which page you want to add page number. The procedures are (in Word 2007) :1. Goto Page Layout->Breaks->Section breaks.2. In Section Breaks zone, you can choose Next Page and some others way to set sections.3. Then when you want to add the page number into next section. Go to Insert->Page Number->Format ...

   Office 2007, Word, Page number, Section,     2011-04-08 04:00:53

  Turn Your Visitors Into Shoppers With Responsive Magento Website

In recent years, there has been an influential growth in the number of internet users across the world. If statistics are to be believed, almost 83% of the web users are engaged over smart devices like Tablets, Mobiles, Ipads, Laptops, Desktop, etc. In 2008, the core community of Magento released a spellbinding web development solution i.e Responsive Magento Website to uniformly serve the target audience. Due to technological advancement in digital realm, there has been a splurged introduction o...

   MAGENTO DEVELOPERS,RESPONSIVE WEBSITE     2015-10-13 01:50:26

  Why 0.1+0.2 != 0.3

In programming languages such as JavaScript, c/c++, Java and Matlab, you will find that you will get unexpected result when doing float point calculation. For example, when calculating 0.1 + 0.1, you will not get 0.3: > 0.1 + 0.2 == 0.3 false > 0.1 + 0.2 0.30000000000000004 Don't be surprised of this result, this is the end result of IEEE 754 standard, float point number cannot be accurately represented according to IEEE 754 because: No enough memory is allocated for representing the num...

   float point,comparison,JavaScript     2014-11-19 05:32:46